clientcountutil

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package clientcountutil provides a library to generate activity log data for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyInput

func VerifyInput(input *generation.ActivityLogMockInput) error

VerifyInput checks that the input data is valid

Types

type ActivityLogDataGenerator

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

ActivityLogDataGenerator holds an ActivityLogMockInput. Users can create the generator with NewActivityLogData(), add content to the generator using the fluent API methods, and generate and write the JSON representation of the input to the Vault API.

func NewActivityLogData

func NewActivityLogData(client *api.Client) *ActivityLogDataGenerator

NewActivityLogData creates a new instance of an activity log data generator The type returned by this function cannot be called concurrently

func (*ActivityLogDataGenerator) ClientsSeen

ClientsSeen adds clients to the month that was most recently opened with NewPreviousMonthData or NewCurrentMonthData.

func (*ActivityLogDataGenerator) NewClientSeen

NewClientSeen adds 1 new client with the given options to the most recently opened month.

func (*ActivityLogDataGenerator) NewClientsSeen

func (d *ActivityLogDataGenerator) NewClientsSeen(n int, opts ...ClientOption) *ActivityLogDataGenerator

NewClientsSeen adds n new clients with the given options to the most recently opened month.

func (*ActivityLogDataGenerator) NewCurrentMonthData

func (d *ActivityLogDataGenerator) NewCurrentMonthData() *ActivityLogDataGenerator

NewCurrentMonthData opens a new month of data for the current month. All clients will continue to be added to this month until a new month is created with NewPreviousMonthData.

func (*ActivityLogDataGenerator) NewPreviousMonthData

func (d *ActivityLogDataGenerator) NewPreviousMonthData(monthsAgo int) *ActivityLogDataGenerator

NewPreviousMonthData opens a new month of data, where the clients will be recorded as having been seen monthsAgo months ago. All clients will continue to be added to this month until a new month is created with NewPreviousMonthData or NewCurrentMonthData.

func (*ActivityLogDataGenerator) RepeatedClientSeen

func (d *ActivityLogDataGenerator) RepeatedClientSeen(opts ...ClientOption) *ActivityLogDataGenerator

RepeatedClientSeen adds 1 client that was seen in the previous month to the month that was most recently opened. This client will have the attributes described by the provided options.

func (*ActivityLogDataGenerator) RepeatedClientSeenFromMonthsAgo

func (d *ActivityLogDataGenerator) RepeatedClientSeenFromMonthsAgo(monthsAgo int, opts ...ClientOption) *ActivityLogDataGenerator

RepeatedClientSeenFromMonthsAgo adds 1 client that was seen in monthsAgo month to the month that was most recently opened. This client will have the attributes described by provided options.

func (*ActivityLogDataGenerator) RepeatedClientsSeen

func (d *ActivityLogDataGenerator) RepeatedClientsSeen(n int, opts ...ClientOption) *ActivityLogDataGenerator

RepeatedClientsSeen adds n clients that were seen in the previous month to the month that was most recently opened. These clients will have the attributes described by provided options.

func (*ActivityLogDataGenerator) RepeatedClientsSeenFromMonthsAgo

func (d *ActivityLogDataGenerator) RepeatedClientsSeenFromMonthsAgo(n, monthsAgo int, opts ...ClientOption) *ActivityLogDataGenerator

RepeatedClientsSeenFromMonthsAgo adds n clients that were seen in monthsAgo month to the month that was most recently opened. These clients will have the attributes described by provided options.

func (*ActivityLogDataGenerator) Segment

Segment starts a segment within the current month. All clients will be added to this segment, until either Segment is called again to create a new open segment, or NewPreviousMonthData or NewCurrentMonthData is called to open a new month.

func (*ActivityLogDataGenerator) SetMonthOptions

func (d *ActivityLogDataGenerator) SetMonthOptions(opts ...MonthOption) *ActivityLogDataGenerator

SetMonthOptions can be called at any time to set options for the open month

func (*ActivityLogDataGenerator) ToJSON

func (d *ActivityLogDataGenerator) ToJSON(writeOptions ...generation.WriteOptions) ([]byte, error)

ToJSON returns the JSON representation of the data

func (*ActivityLogDataGenerator) ToProto

ToProto returns the ActivityLogMockInput protobuf

func (*ActivityLogDataGenerator) Write

func (d *ActivityLogDataGenerator) Write(ctx context.Context, writeOptions ...generation.WriteOptions) ([]string, error)

Write writes the data to the API with the given write options. The method returns the new paths that have been written. Note that the API endpoint will only be present when Vault has been compiled with the "testonly" flag.

type ClientOption

type ClientOption func(client *generation.Client)

ClientOption defines additional options for the client This type and the functions that return it are here for ease of use. A user could also choose to create the *generation.Client themselves, without using a ClientOption

func WithClientID

func WithClientID(id string) ClientOption

WithClientID sets the ID for the client

func WithClientIsNonEntity

func WithClientIsNonEntity() ClientOption

WithClientIsNonEntity sets whether the client is an entity client or a non- entity token client

func WithClientMount

func WithClientMount(m string) ClientOption

WithClientMount sets the mount path for the client

func WithClientNamespace

func WithClientNamespace(n string) ClientOption

WithClientNamespace sets the namespace for the client

func WithClientType

func WithClientType(typ string) ClientOption

WithClientType sets the client type to the given string. If this client type is not "entity", then the client will be counted in the activity log as a non-entity client

type MonthOption

type MonthOption func(m *generation.Data)

MonthOption holds an option that can be set for the entire month

func WithEmptySegmentIndexes

func WithEmptySegmentIndexes(i ...int) MonthOption

WithEmptySegmentIndexes sets which segment indexes should be empty for the segments in the open month. If you use this option, you must either:

  1. ensure that you've called Segment() for the open month
  2. use WithMaximumSegmentIndex() to set the total number of segments

If you haven't set either of those values then this option will be ignored, unless you included 0 as an empty segment index in which case only an empty segment will be created.

func WithMaximumSegmentIndex

func WithMaximumSegmentIndex(n int) MonthOption

WithMaximumSegmentIndex sets the maximum segment index for the segments in the open month. Set this value in order to set how many indexes the data should be split across. This must include any empty or skipped indexes. For example, say that you would like all of your data split across indexes 0 and 3, with the following empty and skipped indexes:

empty indexes: [2]
skipped indexes: [1]

To accomplish that, you will need to call WithMaximumSegmentIndex(3). This value will be ignored if you have called Segment() for the open month If not set, all data will be in 1 segment.

func WithSkipSegmentIndexes

func WithSkipSegmentIndexes(i ...int) MonthOption

WithSkipSegmentIndexes sets which segment indexes should be skipped for the segments in the open month. If you use this option, you must either:

  1. ensure that you've called Segment() for the open month
  2. use WithMaximumSegmentIndex() to set the total number of segments

If you haven't set either of those values then this option will be ignored, unless you included 0 as a skipped segment index in which case no segments will be created.

type SegmentOption

type SegmentOption func(segment *generation.Segment)

SegmentOption defines additional options for the segment

func WithSegmentIndex

func WithSegmentIndex(n int) SegmentOption

WithSegmentIndex sets the index for the segment to n. If this option is not provided, the segment will be given the next consecutive index

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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