anonymize

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AggregateForm = forms.Form{
	ErrorMsg: "invalid data encountered in the aggregation config",
	Fields: []forms.Field{
		{
			Name: "config",
			Validators: []forms.Validator{
				forms.IsOptional{Default: map[string]interface{}{}},
				forms.IsStringMap{},
			},
		},
		{
			Name: "function",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsString{},
				IsFunction{},
			},
		},
		{
			Name: "filters",
			Validators: []forms.Validator{
				forms.IsOptional{Default: []interface{}{}},
				forms.IsList{
					Validators: []forms.Validator{
						forms.IsStringMap{
							Form: &FilterForm,
						},
					},
				},
			},
		},
		{
			Name: "group-by",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsList{
					Validators: []forms.Validator{
						forms.IsStringMap{
							Form: &GroupByForm,
						},
					},
				},
			},
		},
		{
			Name: "result-name",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsString{},
			},
		},
		{
			Name: "finalize-after",
			Validators: []forms.Validator{
				forms.IsOptional{Default: 300},
				forms.IsInteger{Min: -1, HasMin: true},
			},
		},
		{
			Name: "channels",
			Validators: []forms.Validator{
				forms.IsOptional{Default: []string{}},
				forms.IsStringList{},
			},
		},
	},
}
View Source
var Anonymizers = map[string]AnonymizerMaker{
	"aggregate": MakeAggregateAnonymizer,
}
View Source
var FilterForm = forms.Form{
	ErrorMsg: "invalid data encountered in the aggregation filter form",
	Fields: []forms.Field{
		{
			Name: "function",
			Validators: []forms.Validator{
				forms.IsIn{Choices: []interface{}{}},
			},
		},
		{
			Name: "config",
			Validators: []forms.Validator{
				forms.IsStringMap{},
				forms.Switch{
					Key: "function",
					Cases: map[string][]forms.Validator{
						"time-window": {
							forms.IsStringMap{
								Form: &GroupByTimeWindowForm,
							},
						},
						"value": {
							forms.IsStringMap{
								Form: &GroupByValueForm,
							},
						},
					},
				},
			},
		},
	},
}
View Source
var GroupByForm = forms.Form{
	ErrorMsg: "invalid data encountered in the aggregation group-by form",
	Fields: []forms.Field{
		{
			Name: "function",
			Validators: []forms.Validator{
				forms.IsIn{Choices: []interface{}{"time-window", "value"}},
			},
		},
		{
			Name: "always-included",
			Validators: []forms.Validator{
				forms.IsOptional{Default: false},
				forms.IsBoolean{},
			},
		},
		{
			Name: "config",
			Validators: []forms.Validator{
				forms.IsStringMap{},
				forms.Switch{
					Key: "function",
					Cases: map[string][]forms.Validator{
						"time-window": {
							forms.IsStringMap{
								Form: &GroupByTimeWindowForm,
							},
						},
						"value": {
							forms.IsStringMap{
								Form: &GroupByValueForm,
							},
						},
					},
				},
			},
		},
	},
}
View Source
var GroupByTimeWindowForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "field",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "format",
			Validators: []forms.Validator{
				forms.IsString{},
				forms.IsIn{Choices: timeFormatValues()},
			},
		},
		{
			Name: "window",
			Validators: []forms.Validator{
				forms.Or{
					Options: [][]forms.Validator{
						[]forms.Validator{
							forms.IsString{},
							forms.IsIn{Choices: timeWindowValues()},
						},
						[]forms.Validator{
							forms.IsList{
								Validators: []forms.Validator{
									forms.IsString{},
									forms.IsIn{Choices: timeWindowValues()},
								},
							},
						},
					},
				},
			},
		},
	},
}
View Source
var GroupByValueForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "field",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "is-list",
			Validators: []forms.Validator{
				forms.IsOptional{Default: false},
				forms.IsBoolean{},
			},
		},
		{
			Name: "index",
			Validators: []forms.Validator{
				forms.IsOptional{Default: 0},
				forms.IsInteger{HasMin: true, Min: 0},
			},
		},
	},
}

Functions

This section is empty.

Types

type AggregateAnonymizer

type AggregateAnonymizer struct {
	// contains filtered or unexported fields
}

func (*AggregateAnonymizer) Advance

func (a *AggregateAnonymizer) Advance(channelWriter kodex.ChannelWriter) ([]*kodex.Item, error)

func (*AggregateAnonymizer) Anonymize

func (a *AggregateAnonymizer) Anonymize(item *kodex.Item, writer kodex.ChannelWriter) (*kodex.Item, error)

func (*AggregateAnonymizer) Finalize

func (a *AggregateAnonymizer) Finalize(writer kodex.ChannelWriter) ([]*kodex.Item, error)

func (*AggregateAnonymizer) GenerateParams

func (a *AggregateAnonymizer) GenerateParams(key, salt []byte) error

func (*AggregateAnonymizer) Params

func (a *AggregateAnonymizer) Params() interface{}

func (*AggregateAnonymizer) Reset

func (a *AggregateAnonymizer) Reset() error

func (*AggregateAnonymizer) SetParams

func (a *AggregateAnonymizer) SetParams(params interface{}) error

func (*AggregateAnonymizer) Setup

func (a *AggregateAnonymizer) Setup(settings kodex.Settings) error

func (*AggregateAnonymizer) Teardown

func (a *AggregateAnonymizer) Teardown() error

type Anonymizer

type Anonymizer interface {
	Setup(kodex.Settings) error
	Teardown() error
	Reset() error
	Advance(kodex.ChannelWriter) ([]*kodex.Item, error)
	Finalize(kodex.ChannelWriter) ([]*kodex.Item, error)
	Anonymize(*kodex.Item, kodex.ChannelWriter) (*kodex.Item, error)
}

func MakeAggregateAnonymizer

func MakeAggregateAnonymizer(name string, id []byte, config map[string]interface{}) (Anonymizer, error)

type AnonymizerMaker

type AnonymizerMaker func(name string, id []byte, config map[string]interface{}) (Anonymizer, error)

type Function

type Function struct {
	Function aggregate.Function
	Name     string
	Config   map[string]interface{}
}

type IsFunction

type IsFunction struct{}

func (IsFunction) Validate

func (i IsFunction) Validate(input interface{}, values map[string]interface{}) (interface{}, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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