database

package
v0.0.0-...-6cfc1b2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package database is a generated GoMock package.

Package database is a generated GoMock package.

Package database is a generated GoMock package.

Index

Constants

View Source
const (
	FakeDataEnvVar   = "FAKE_DATA"
	FakeTracesEnvVar = "FAKE_TRACES"
)
View Source
const (
	DBDriverTypePostgres = "POSTGRES"
	DBDriverTypeLocal    = "LOCAL"
)
View Source
const (
	ReconstructedSpecType specType = "ReconstructedSpecType"
	ProvidedSpecType      specType = "ProvidedSpecType"
)

Variables

This section is empty.

Functions

func APIEventFromDB

func APIEventFromDB(event *APIEvent) *models.APIEvent

func APIInfoFromDB

func APIInfoFromDB(apiInfo *APIInfo) *models.APIInfo

func CreateSortOrder

func CreateSortOrder(sortKey string, sortDir *string) (string, error)

func CreateTimeFilter

func CreateTimeFilter(columnName string, startTime, endTime strfmt.DateTime) string

func FieldInTable

func FieldInTable(table, field string) string

func FilterContains

func FilterContains(db *gorm.DB, column string, values []string) *gorm.DB

func FilterEndsWith

func FilterEndsWith(db *gorm.DB, column string, value *string) *gorm.DB

func FilterGte

func FilterGte(db *gorm.DB, column string, value *string) *gorm.DB

func FilterIs

func FilterIs(db *gorm.DB, column string, values []string) *gorm.DB

func FilterIsBool

func FilterIsBool(db *gorm.DB, column string, value *bool) *gorm.DB

func FilterIsNot

func FilterIsNot(db *gorm.DB, column string, values []string) *gorm.DB

func FilterIsNotInAnnotations

func FilterIsNotInAnnotations(db *gorm.DB, column string, values []string) *gorm.DB

func FilterIsOrNull

func FilterIsOrNull(db *gorm.DB, column string, values []string) *gorm.DB

func FilterIsUint32

func FilterIsUint32(db *gorm.DB, column string, value *uint32) *gorm.DB

func FilterLte

func FilterLte(db *gorm.DB, column string, value *string) *gorm.DB

func FilterStartsWith

func FilterStartsWith(db *gorm.DB, column string, value *string) *gorm.DB

func GenerateTraceSourceToken

func GenerateTraceSourceToken() (string, error)

func Paginate

func Paginate(page, pageSize int64) func(db *gorm.DB) *gorm.DB

Types

type APIAnnotationsTable

type APIAnnotationsTable interface {
	UpdateOrCreate(ctx context.Context, am ...APIInfoAnnotation) error
	Get(ctx context.Context, modName string, apiID uint, name string) (*APIInfoAnnotation, error)
	List(ctx context.Context, modName string, apiID uint) ([]*APIInfoAnnotation, error)
	Delete(ctx context.Context, modName string, apiID uint, names ...string) error
	DeleteAll(ctx context.Context, modName string, apiID uint) error
}

type APIEvent

type APIEvent struct {
	// will be populated after inserting to DB
	ID uint `gorm:"primarykey" faker:"-"`

	Time                     strfmt.DateTime   `json:"time" gorm:"column:time" faker:"-"`
	RequestTime              strfmt.DateTime   `json:"requestTime" gorm:"column:request_time" faker:"-"`
	Method                   models.HTTPMethod `json:"method,omitempty" gorm:"column:method" faker:"oneof: GET, PUT, POST, DELETE"`
	Path                     string            `json:"path,omitempty" gorm:"column:path" faker:"oneof: /news, /customers, /jokes"`
	ProvidedPathID           string            `json:"providedPathId,omitempty" gorm:"column:provided_path_id" faker:"-"`
	ReconstructedPathID      string            `json:"reconstructedPathId,omitempty" gorm:"column:reconstructed_path_id" faker:"-"`
	Query                    string            `json:"query,omitempty" gorm:"column:query" faker:"oneof: name=ferret&color=purple, foo=bar, -"`
	StatusCode               int64             `json:"statusCode,omitempty" gorm:"column:status_code" faker:"oneof: 200, 401, 404, 500"`
	SourceIP                 string            `json:"sourceIP,omitempty" gorm:"column:source_ip" faker:"sourceIP"`
	DestinationIP            string            `json:"destinationIP,omitempty" gorm:"column:destination_ip" faker:"destinationIP"`
	DestinationPort          int64             `json:"destinationPort,omitempty" gorm:"column:destination_port" faker:"oneof: 80, 443"`
	HasReconstructedSpecDiff bool              `json:"hasReconstructedSpecDiff,omitempty" gorm:"column:has_reconstructed_spec_diff"`
	HasProvidedSpecDiff      bool              `json:"hasProvidedSpecDiff,omitempty" gorm:"column:has_provided_spec_diff"`
	HasSpecDiff              bool              `json:"hasSpecDiff,omitempty" gorm:"column:has_spec_diff"`
	SpecDiffType             models.DiffType   `json:"specDiffType,omitempty" gorm:"column:spec_diff_type" faker:"oneof: ZOMBIE_DIFF, SHADOW_DIFF, GENERAL_DIFF, NO_DIFF"`
	HostSpecName             string            `json:"hostSpecName,omitempty" gorm:"column:host_spec_name" faker:"oneof: test.com, example.com, kaki.org"`
	IsNonAPI                 bool              `json:"isNonApi,omitempty" gorm:"column:is_non_api" faker:"-"`

	// Spec diff info
	// New reconstructed spec json string
	NewReconstructedSpec string `json:"newReconstructedSpec,omitempty" gorm:"column:new_reconstructed_spec" faker:"-"`
	// Old reconstructed spec json string
	OldReconstructedSpec string `json:"oldReconstructedSpec,omitempty" gorm:"column:old_reconstructed_spec" faker:"-"`
	// New provided spec json string
	NewProvidedSpec string `json:"newProvidedSpec,omitempty" gorm:"column:new_provided_spec" faker:"-"`
	// Old provided spec json string
	OldProvidedSpec string `json:"oldProvidedSpec,omitempty" gorm:"column:old_provided_spec" faker:"-"`

	// ID for the relevant APIInfo
	APIInfoID uint `json:"apiInfoId,omitempty" gorm:"column:api_info_id" faker:"-"`
	// We'll not always have a corresponding API info (e.g. non-API resources) so the type is needed also for the event
	EventType models.APIType `json:"eventType,omitempty" gorm:"column:event_type" faker:"oneof: INTERNAL, EXTERNAL"`

	Annotations []*APIEventAnnotation `gorm:"foreignKey:EventID;references:ID;constraint:OnDelete:CASCADE"`
	APIInfo     APIInfo               `gorm:"constraint:OnDelete:CASCADE"`
}

func (APIEvent) TableName

func (APIEvent) TableName() string

type APIEventAnnotation

type APIEventAnnotation struct {
	// will be populated after inserting to DB
	ID         uint   `gorm:"primarykey" faker:"-"`
	ModuleName string `json:"module_name,omitempty" gorm:"column:module_name;uniqueIndex:api_event_ann_idx_model" faker:"-"`
	EventID    uint   `json:"event_id,omitempty" gorm:"column:event_id;uniqueIndex:api_event_ann_idx_model" faker:"-"`
	Name       string `json:"name,omitempty" gorm:"column:name;uniqueIndex:api_event_ann_idx_model" faker:"-"`
	Annotation []byte `json:"annotation,omitempty" gorm:"column:annotation" faker:"-"`
}

func (APIEventAnnotation) TableName

func (APIEventAnnotation) TableName() string

type APIEventAnnotationFilters

type APIEventAnnotationFilters struct {
	NoAnnotations bool

	ModuleNameIs *string
	NameIs       *string
	ValueIs      *string

	ModuleNameIsNot *string
	NameIsNot       *string
	ValueIsNot      *string
}

type APIEventAnnotationTable

type APIEventAnnotationTable interface {
	Create(ctx context.Context, eas ...APIEventAnnotation) error
	Get(ctx context.Context, modName string, eventID uint, name string) (*APIEventAnnotation, error)
	List(ctx context.Context, modName string, eventID uint) ([]*APIEventAnnotation, error)
}

type APIEventAnnotationTableHandler

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

func (*APIEventAnnotationTableHandler) Create

func (ea *APIEventAnnotationTableHandler) Create(ctx context.Context, annotations ...APIEventAnnotation) error

func (*APIEventAnnotationTableHandler) Get

func (ea *APIEventAnnotationTableHandler) Get(ctx context.Context, modName string, eventID uint, name string) (*APIEventAnnotation, error)

func (*APIEventAnnotationTableHandler) List

func (ea *APIEventAnnotationTableHandler) List(ctx context.Context, modName string, eventID uint) ([]*APIEventAnnotation, error)

type APIEventsFilters

type APIEventsFilters struct {
	DestinationIPIsNot    []string
	DestinationIPIs       []string
	DestinationPortIsNot  []string
	DestinationPortIs     []string
	EndTime               *strfmt.DateTime
	RequestEndTime        *strfmt.DateTime
	ShowNonAPI            bool
	HasSpecDiffIs         *bool
	SpecDiffTypeIs        []string
	MethodIs              []string
	ReconstructedPathIDIs []string
	ProvidedPathIDIs      []string
	PathContains          []string
	PathEnd               *string
	PathIsNot             []string
	PathIs                []string
	PathStart             *string
	SourceIPIsNot         []string
	SourceIPIs            []string
	SpecContains          []string
	SpecEnd               *string
	SpecIsNot             []string
	SpecIs                []string
	SpecStart             *string
	StartTime             *strfmt.DateTime
	RequestStartTime      *strfmt.DateTime
	StatusCodeGte         *string
	StatusCodeIsNot       []string
	StatusCodeIs          []string
	StatusCodeLte         *string
	APIInfoIDIs           *uint32
}

type APIEventsTable

type APIEventsTable interface {
	GetAPIEventsWithAnnotations(ctx context.Context, filters GetAPIEventsQuery) ([]*APIEvent, error)
	GetAPIEventsAndTotal(params operations.GetAPIEventsParams) ([]APIEvent, int64, error)
	GetAPIEvent(eventID uint32) (*APIEvent, error)
	GetAPIEventReconstructedSpecDiff(eventID uint32) (*APIEvent, error)
	GetAPIEventProvidedSpecDiff(eventID uint32) (*APIEvent, error)
	SetAPIEventsReconstructedPathID(approvedReview []*speculatorspec.ApprovedSpecReviewPathItem, host string, port string) error
	GetAPIEventsLatestDiffs(latestDiffsNum int) ([]APIEvent, error)
	GetAPIUsages(params operations.GetAPIUsageHitCountParams) ([]*models.HitCount, error)
	GetDashboardAPIUsages(startTime, endTime time.Time, apiType APIUsageType) ([]*models.APIUsage, error)
	CreateAPIEvent(event *APIEvent)
	UpdateAPIEvent(event *APIEvent) error
	GroupByAPIInfo() ([]HostGroup, error)
}

type APIEventsTableHandler

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

func (*APIEventsTableHandler) CreateAPIEvent

func (a *APIEventsTableHandler) CreateAPIEvent(event *APIEvent)

func (*APIEventsTableHandler) GetAPIEvent

func (a *APIEventsTableHandler) GetAPIEvent(eventID uint32) (*APIEvent, error)

func (*APIEventsTableHandler) GetAPIEventProvidedSpecDiff

func (a *APIEventsTableHandler) GetAPIEventProvidedSpecDiff(eventID uint32) (*APIEvent, error)

func (*APIEventsTableHandler) GetAPIEventReconstructedSpecDiff

func (a *APIEventsTableHandler) GetAPIEventReconstructedSpecDiff(eventID uint32) (*APIEvent, error)

func (*APIEventsTableHandler) GetAPIEventsAndTotal

func (a *APIEventsTableHandler) GetAPIEventsAndTotal(params operations.GetAPIEventsParams) ([]APIEvent, int64, error)

func (*APIEventsTableHandler) GetAPIEventsLatestDiffs

func (a *APIEventsTableHandler) GetAPIEventsLatestDiffs(latestDiffsNum int) ([]APIEvent, error)

func (*APIEventsTableHandler) GetAPIEventsWithAnnotations

func (a *APIEventsTableHandler) GetAPIEventsWithAnnotations(ctx context.Context, query GetAPIEventsQuery) ([]*APIEvent, error)

func (*APIEventsTableHandler) GetAPIUsages

func (*APIEventsTableHandler) GetDashboardAPIUsages

func (a *APIEventsTableHandler) GetDashboardAPIUsages(startTime, endTime time.Time, apiType APIUsageType) ([]*models.APIUsage, error)

func (*APIEventsTableHandler) GroupByAPIInfo

func (a *APIEventsTableHandler) GroupByAPIInfo() ([]HostGroup, error)

func (*APIEventsTableHandler) SetAPIEventsReconstructedPathID

func (a *APIEventsTableHandler) SetAPIEventsReconstructedPathID(approvedReview []*speculatorspec.ApprovedSpecReviewPathItem, host string, port string) error

SetAPIEventsReconstructedPathID will set reconstructed path ID for all events with the provided paths, host and port.

func (*APIEventsTableHandler) UpdateAPIEvent

func (a *APIEventsTableHandler) UpdateAPIEvent(event *APIEvent) error

type APIInfo

type APIInfo struct {
	// will be populated after inserting to DB
	ID uint `json:"id,omitempty" gorm:"primarykey" faker:"-"`

	Type                       models.APIType  `json:"type,omitempty" gorm:"column:type;uniqueIndex:api_info_idx_model" faker:"oneof: INTERNAL, EXTERNAL"`
	Name                       string          `json:"name,omitempty" gorm:"column:name;uniqueIndex:api_info_idx_model" faker:"oneof: test.com, example.com, kaki.org"`
	Port                       int64           `json:"port,omitempty" gorm:"column:port;uniqueIndex:api_info_idx_model" faker:"oneof: 80, 443"`
	TraceSourceID              uint            `json:"traceSourceID,omitempty" gorm:"column:trace_source_id;default:0;uniqueIndex:api_info_idx_model" faker:"-"` // This is the name of the Trace Source which notified of this API. Empty means it was auto discovered by APIClarity on first.
	HasProvidedSpec            bool            `json:"hasProvidedSpec,omitempty" gorm:"column:has_provided_spec"`
	HasReconstructedSpec       bool            `json:"hasReconstructedSpec,omitempty" gorm:"column:has_reconstructed_spec"`
	ReconstructedSpec          string          `json:"reconstructedSpec,omitempty" gorm:"column:reconstructed_spec" faker:"-"`
	ReconstructedSpecInfo      string          `json:"reconstructedSpecInfo,omitempty" gorm:"column:reconstructed_spec_info" faker:"-"`
	ProvidedSpec               string          `json:"providedSpec,omitempty" gorm:"column:provided_spec" faker:"-"`
	ProvidedSpecInfo           string          `json:"providedSpecInfo,omitempty" gorm:"column:provided_spec_info" faker:"-"`
	DestinationNamespace       string          `json:"destinationNamespace,omitempty" gorm:"column:destination_namespace;uniqueIndex:api_info_idx_model" faker:"-"`
	ProvidedSpecCreatedAt      strfmt.DateTime `json:"providedSpecCreatedAt,omitempty" gorm:"column:provided_spec_created_at" faker:"-"`
	ReconstructedSpecCreatedAt strfmt.DateTime `json:"reconstructedSpecCreatedAt,omitempty" gorm:"column:reconstructed_spec_created_at" faker:"-"`

	TraceSource TraceSource          `gorm:"constraint:OnDelete:CASCADE"`
	Annotations []*APIInfoAnnotation `gorm:"foreignKey:APIID;references:ID;constraint:OnDelete:CASCADE"`
}

func (APIInfo) TableName

func (APIInfo) TableName() string

type APIInfoAnnotation

type APIInfoAnnotation struct {
	ID         uint   `gorm:"primarykey" faker:"-"`
	ModuleName string `json:"module_name,omitempty" gorm:"column:module_name;uniqueIndex:api_ann_idx_model" faker:"-"`
	APIID      uint   `json:"api_id,omitempty" gorm:"column:api_id;uniqueIndex:api_ann_idx_model" faker:"-"`
	Name       string `json:"name,omitempty" gorm:"column:name;uniqueIndex:api_ann_idx_model" faker:"-"`
	Annotation []byte `json:"annotation,omitempty" gorm:"column:annotation" faker:"-"`
}

func (APIInfoAnnotation) TableName

func (APIInfoAnnotation) TableName() string

type APIInfoAnnotationsTableHandler

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

func (*APIInfoAnnotationsTableHandler) Delete

func (am *APIInfoAnnotationsTableHandler) Delete(ctx context.Context, modName string, apiID uint, names ...string) error

func (*APIInfoAnnotationsTableHandler) DeleteAll

func (am *APIInfoAnnotationsTableHandler) DeleteAll(ctx context.Context, modName string, apiID uint) error

func (*APIInfoAnnotationsTableHandler) Get

func (am *APIInfoAnnotationsTableHandler) Get(ctx context.Context, modName string, apiID uint, name string) (*APIInfoAnnotation, error)

func (*APIInfoAnnotationsTableHandler) List

func (am *APIInfoAnnotationsTableHandler) List(ctx context.Context, modName string, apiID uint) ([]*APIInfoAnnotation, error)

func (*APIInfoAnnotationsTableHandler) UpdateOrCreate

func (am *APIInfoAnnotationsTableHandler) UpdateOrCreate(ctx context.Context, annotations ...APIInfoAnnotation) error

type APIInventoryTable

type APIInventoryTable interface {
	GetAPIInventoryAndTotal(params operations.GetAPIInventoryParams) ([]APIInfo, int64, error)
	GetAPISpecs(apiID uint32) (*APIInfo, error)
	GetAPISpecsInfo(apiID uint32) (*models.OpenAPISpecs, error)
	PutAPISpec(apiID uint, spec string, specInfo *models.SpecInfo, specType specType, createdAt strfmt.DateTime) error
	DeleteProvidedAPISpec(apiID uint32) error
	DeleteApprovedAPISpec(apiID uint32) error
	GetAPIID(name, port string, traceSourceID *uuid.UUID) (uint, error)
	First(dest *APIInfo, conds ...interface{}) error
	FirstOrCreate(apiInfo *APIInfo) (created bool, err error)
	CreateAPIInfo(event *APIInfo)
}

type APIInventoryTableHandler

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

func (*APIInventoryTableHandler) CreateAPIInfo

func (a *APIInventoryTableHandler) CreateAPIInfo(event *APIInfo)

func (*APIInventoryTableHandler) DeleteApprovedAPISpec

func (a *APIInventoryTableHandler) DeleteApprovedAPISpec(apiID uint32) error

func (*APIInventoryTableHandler) DeleteProvidedAPISpec

func (a *APIInventoryTableHandler) DeleteProvidedAPISpec(apiID uint32) error

func (*APIInventoryTableHandler) First

func (a *APIInventoryTableHandler) First(dest *APIInfo, conds ...interface{}) error

func (*APIInventoryTableHandler) FirstOrCreate

func (a *APIInventoryTableHandler) FirstOrCreate(apiInfo *APIInfo) (created bool, err error)

func (*APIInventoryTableHandler) GetAPIID

func (a *APIInventoryTableHandler) GetAPIID(name, port string, traceSourceID *uuid.UUID) (uint, error)

func (*APIInventoryTableHandler) GetAPIInventoryAndTotal

func (a *APIInventoryTableHandler) GetAPIInventoryAndTotal(params operations.GetAPIInventoryParams) ([]APIInfo, int64, error)

func (*APIInventoryTableHandler) GetAPISpecs

func (a *APIInventoryTableHandler) GetAPISpecs(apiID uint32) (*APIInfo, error)

func (*APIInventoryTableHandler) GetAPISpecsInfo

func (a *APIInventoryTableHandler) GetAPISpecsInfo(apiID uint32) (*models.OpenAPISpecs, error)

func (*APIInventoryTableHandler) PutAPISpec

func (a *APIInventoryTableHandler) PutAPISpec(apiID uint, spec string, specInfo *models.SpecInfo, specType specType, createdAt strfmt.DateTime) error

type APIUsageType

type APIUsageType string
const (
	APIWithDiffs APIUsageType = "APIWithDiffs"
	ExistingAPI  APIUsageType = "ExistingAPI"
	NewAPI       APIUsageType = "NewAPI"
)

type DBConfig

type DBConfig struct {
	EnableInfoLogs bool
	DriverType     string
	DBPassword     string
	DBUser         string
	DBHost         string
	DBPort         string
	DBName         string
}

type Database

type Database interface {
	APIEventsTable() APIEventsTable
	APIInventoryTable() APIInventoryTable
	ReviewTable() ReviewTable
	APIEventsAnnotationsTable() APIEventAnnotationTable
	APIInfoAnnotationsTable() APIAnnotationsTable
	TraceSourcesTable() TraceSourcesTable
	TraceSamplingTable() TraceSamplingTable
}

type GetAPIEventsQuery

type GetAPIEventsQuery struct {
	EventID *uint32

	Offset     int
	Limit      int
	Order      string
	AscSortDir bool

	APIEventsFilters          *APIEventsFilters
	APIEventAnnotationFilters *APIEventAnnotationFilters
}

type Handler

type Handler struct {
	DB *gorm.DB
}

func Init

func Init(config *DBConfig) *Handler

func (*Handler) APIEventsAnnotationsTable

func (db *Handler) APIEventsAnnotationsTable() APIEventAnnotationTable

func (*Handler) APIEventsTable

func (db *Handler) APIEventsTable() APIEventsTable

func (*Handler) APIInfoAnnotationsTable

func (db *Handler) APIInfoAnnotationsTable() APIAnnotationsTable

func (*Handler) APIInventoryTable

func (db *Handler) APIInventoryTable() APIInventoryTable

func (*Handler) CreateFakeData

func (db *Handler) CreateFakeData()

func (*Handler) ReviewTable

func (db *Handler) ReviewTable() ReviewTable

func (*Handler) StartReviewTableCleaner

func (db *Handler) StartReviewTableCleaner(ctx context.Context, cleanInterval time.Duration)

func (*Handler) TraceSamplingTable

func (db *Handler) TraceSamplingTable() TraceSamplingTable

func (*Handler) TraceSourcesTable

func (db *Handler) TraceSourcesTable() TraceSourcesTable

type HostGroup

type HostGroup struct {
	HostSpecName string
	Port         int64
	APIType      string
	APIInfoID    uint32
	Count        int
}

type MockAPIEventsTable

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

MockAPIEventsTable is a mock of APIEventsTable interface.

func NewMockAPIEventsTable

func NewMockAPIEventsTable(ctrl *gomock.Controller) *MockAPIEventsTable

NewMockAPIEventsTable creates a new mock instance.

func (*MockAPIEventsTable) CreateAPIEvent

func (m *MockAPIEventsTable) CreateAPIEvent(arg0 *APIEvent)

CreateAPIEvent mocks base method.

func (*MockAPIEventsTable) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAPIEventsTable) GetAPIEvent

func (m *MockAPIEventsTable) GetAPIEvent(arg0 uint32) (*APIEvent, error)

GetAPIEvent mocks base method.

func (*MockAPIEventsTable) GetAPIEventProvidedSpecDiff

func (m *MockAPIEventsTable) GetAPIEventProvidedSpecDiff(arg0 uint32) (*APIEvent, error)

GetAPIEventProvidedSpecDiff mocks base method.

func (*MockAPIEventsTable) GetAPIEventReconstructedSpecDiff

func (m *MockAPIEventsTable) GetAPIEventReconstructedSpecDiff(arg0 uint32) (*APIEvent, error)

GetAPIEventReconstructedSpecDiff mocks base method.

func (*MockAPIEventsTable) GetAPIEventsAndTotal

func (m *MockAPIEventsTable) GetAPIEventsAndTotal(arg0 operations.GetAPIEventsParams) ([]APIEvent, int64, error)

GetAPIEventsAndTotal mocks base method.

func (*MockAPIEventsTable) GetAPIEventsLatestDiffs

func (m *MockAPIEventsTable) GetAPIEventsLatestDiffs(arg0 int) ([]APIEvent, error)

GetAPIEventsLatestDiffs mocks base method.

func (*MockAPIEventsTable) GetAPIEventsWithAnnotations

func (m *MockAPIEventsTable) GetAPIEventsWithAnnotations(arg0 context.Context, arg1 GetAPIEventsQuery) ([]*APIEvent, error)

GetAPIEventsWithAnnotations mocks base method.

func (*MockAPIEventsTable) GetAPIUsages

GetAPIUsages mocks base method.

func (*MockAPIEventsTable) GetDashboardAPIUsages

func (m *MockAPIEventsTable) GetDashboardAPIUsages(arg0, arg1 time.Time, arg2 APIUsageType) ([]*models.APIUsage, error)

GetDashboardAPIUsages mocks base method.

func (*MockAPIEventsTable) GroupByAPIInfo

func (m *MockAPIEventsTable) GroupByAPIInfo() ([]HostGroup, error)

GroupByAPIInfo mocks base method.

func (*MockAPIEventsTable) SetAPIEventsReconstructedPathID

func (m *MockAPIEventsTable) SetAPIEventsReconstructedPathID(arg0 []*spec.ApprovedSpecReviewPathItem, arg1, arg2 string) error

SetAPIEventsReconstructedPathID mocks base method.

func (*MockAPIEventsTable) UpdateAPIEvent

func (m *MockAPIEventsTable) UpdateAPIEvent(arg0 *APIEvent) error

UpdateAPIEvent mocks base method.

type MockAPIEventsTableMockRecorder

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

MockAPIEventsTableMockRecorder is the mock recorder for MockAPIEventsTable.

func (*MockAPIEventsTableMockRecorder) CreateAPIEvent

func (mr *MockAPIEventsTableMockRecorder) CreateAPIEvent(arg0 interface{}) *gomock.Call

CreateAPIEvent indicates an expected call of CreateAPIEvent.

func (*MockAPIEventsTableMockRecorder) GetAPIEvent

func (mr *MockAPIEventsTableMockRecorder) GetAPIEvent(arg0 interface{}) *gomock.Call

GetAPIEvent indicates an expected call of GetAPIEvent.

func (*MockAPIEventsTableMockRecorder) GetAPIEventProvidedSpecDiff

func (mr *MockAPIEventsTableMockRecorder) GetAPIEventProvidedSpecDiff(arg0 interface{}) *gomock.Call

GetAPIEventProvidedSpecDiff indicates an expected call of GetAPIEventProvidedSpecDiff.

func (*MockAPIEventsTableMockRecorder) GetAPIEventReconstructedSpecDiff

func (mr *MockAPIEventsTableMockRecorder) GetAPIEventReconstructedSpecDiff(arg0 interface{}) *gomock.Call

GetAPIEventReconstructedSpecDiff indicates an expected call of GetAPIEventReconstructedSpecDiff.

func (*MockAPIEventsTableMockRecorder) GetAPIEventsAndTotal

func (mr *MockAPIEventsTableMockRecorder) GetAPIEventsAndTotal(arg0 interface{}) *gomock.Call

GetAPIEventsAndTotal indicates an expected call of GetAPIEventsAndTotal.

func (*MockAPIEventsTableMockRecorder) GetAPIEventsLatestDiffs

func (mr *MockAPIEventsTableMockRecorder) GetAPIEventsLatestDiffs(arg0 interface{}) *gomock.Call

GetAPIEventsLatestDiffs indicates an expected call of GetAPIEventsLatestDiffs.

func (*MockAPIEventsTableMockRecorder) GetAPIEventsWithAnnotations

func (mr *MockAPIEventsTableMockRecorder) GetAPIEventsWithAnnotations(arg0, arg1 interface{}) *gomock.Call

GetAPIEventsWithAnnotations indicates an expected call of GetAPIEventsWithAnnotations.

func (*MockAPIEventsTableMockRecorder) GetAPIUsages

func (mr *MockAPIEventsTableMockRecorder) GetAPIUsages(arg0 interface{}) *gomock.Call

GetAPIUsages indicates an expected call of GetAPIUsages.

func (*MockAPIEventsTableMockRecorder) GetDashboardAPIUsages

func (mr *MockAPIEventsTableMockRecorder) GetDashboardAPIUsages(arg0, arg1, arg2 interface{}) *gomock.Call

GetDashboardAPIUsages indicates an expected call of GetDashboardAPIUsages.

func (*MockAPIEventsTableMockRecorder) GroupByAPIInfo

func (mr *MockAPIEventsTableMockRecorder) GroupByAPIInfo() *gomock.Call

GroupByAPIInfo indicates an expected call of GroupByAPIInfo.

func (*MockAPIEventsTableMockRecorder) SetAPIEventsReconstructedPathID

func (mr *MockAPIEventsTableMockRecorder) SetAPIEventsReconstructedPathID(arg0, arg1, arg2 interface{}) *gomock.Call

SetAPIEventsReconstructedPathID indicates an expected call of SetAPIEventsReconstructedPathID.

func (*MockAPIEventsTableMockRecorder) UpdateAPIEvent

func (mr *MockAPIEventsTableMockRecorder) UpdateAPIEvent(arg0 interface{}) *gomock.Call

UpdateAPIEvent indicates an expected call of UpdateAPIEvent.

type MockAPIInventoryTable

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

MockAPIInventoryTable is a mock of APIInventoryTable interface.

func NewMockAPIInventoryTable

func NewMockAPIInventoryTable(ctrl *gomock.Controller) *MockAPIInventoryTable

NewMockAPIInventoryTable creates a new mock instance.

func (*MockAPIInventoryTable) CreateAPIInfo

func (m *MockAPIInventoryTable) CreateAPIInfo(arg0 *APIInfo)

CreateAPIInfo mocks base method.

func (*MockAPIInventoryTable) DeleteApprovedAPISpec

func (m *MockAPIInventoryTable) DeleteApprovedAPISpec(arg0 uint32) error

DeleteApprovedAPISpec mocks base method.

func (*MockAPIInventoryTable) DeleteProvidedAPISpec

func (m *MockAPIInventoryTable) DeleteProvidedAPISpec(arg0 uint32) error

DeleteProvidedAPISpec mocks base method.

func (*MockAPIInventoryTable) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAPIInventoryTable) First

func (m *MockAPIInventoryTable) First(arg0 *APIInfo, arg1 ...interface{}) error

First mocks base method.

func (*MockAPIInventoryTable) FirstOrCreate

func (m *MockAPIInventoryTable) FirstOrCreate(arg0 *APIInfo) (bool, error)

FirstOrCreate mocks base method.

func (*MockAPIInventoryTable) GetAPIID

func (m *MockAPIInventoryTable) GetAPIID(arg0, arg1 string, arg2 *uuid.UUID) (uint, error)

GetAPIID mocks base method.

func (*MockAPIInventoryTable) GetAPIInventoryAndTotal

func (m *MockAPIInventoryTable) GetAPIInventoryAndTotal(arg0 operations.GetAPIInventoryParams) ([]APIInfo, int64, error)

GetAPIInventoryAndTotal mocks base method.

func (*MockAPIInventoryTable) GetAPISpecs

func (m *MockAPIInventoryTable) GetAPISpecs(arg0 uint32) (*APIInfo, error)

GetAPISpecs mocks base method.

func (*MockAPIInventoryTable) GetAPISpecsInfo

func (m *MockAPIInventoryTable) GetAPISpecsInfo(arg0 uint32) (*models.OpenAPISpecs, error)

GetAPISpecsInfo mocks base method.

func (*MockAPIInventoryTable) PutAPISpec

func (m *MockAPIInventoryTable) PutAPISpec(arg0 uint, arg1 string, arg2 *models.SpecInfo, arg3 specType, arg4 strfmt.DateTime) error

PutAPISpec mocks base method.

type MockAPIInventoryTableMockRecorder

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

MockAPIInventoryTableMockRecorder is the mock recorder for MockAPIInventoryTable.

func (*MockAPIInventoryTableMockRecorder) CreateAPIInfo

func (mr *MockAPIInventoryTableMockRecorder) CreateAPIInfo(arg0 interface{}) *gomock.Call

CreateAPIInfo indicates an expected call of CreateAPIInfo.

func (*MockAPIInventoryTableMockRecorder) DeleteApprovedAPISpec

func (mr *MockAPIInventoryTableMockRecorder) DeleteApprovedAPISpec(arg0 interface{}) *gomock.Call

DeleteApprovedAPISpec indicates an expected call of DeleteApprovedAPISpec.

func (*MockAPIInventoryTableMockRecorder) DeleteProvidedAPISpec

func (mr *MockAPIInventoryTableMockRecorder) DeleteProvidedAPISpec(arg0 interface{}) *gomock.Call

DeleteProvidedAPISpec indicates an expected call of DeleteProvidedAPISpec.

func (*MockAPIInventoryTableMockRecorder) First

func (mr *MockAPIInventoryTableMockRecorder) First(arg0 interface{}, arg1 ...interface{}) *gomock.Call

First indicates an expected call of First.

func (*MockAPIInventoryTableMockRecorder) FirstOrCreate

func (mr *MockAPIInventoryTableMockRecorder) FirstOrCreate(arg0 interface{}) *gomock.Call

FirstOrCreate indicates an expected call of FirstOrCreate.

func (*MockAPIInventoryTableMockRecorder) GetAPIID

func (mr *MockAPIInventoryTableMockRecorder) GetAPIID(arg0, arg1, arg2 interface{}) *gomock.Call

GetAPIID indicates an expected call of GetAPIID.

func (*MockAPIInventoryTableMockRecorder) GetAPIInventoryAndTotal

func (mr *MockAPIInventoryTableMockRecorder) GetAPIInventoryAndTotal(arg0 interface{}) *gomock.Call

GetAPIInventoryAndTotal indicates an expected call of GetAPIInventoryAndTotal.

func (*MockAPIInventoryTableMockRecorder) GetAPISpecs

func (mr *MockAPIInventoryTableMockRecorder) GetAPISpecs(arg0 interface{}) *gomock.Call

GetAPISpecs indicates an expected call of GetAPISpecs.

func (*MockAPIInventoryTableMockRecorder) GetAPISpecsInfo

func (mr *MockAPIInventoryTableMockRecorder) GetAPISpecsInfo(arg0 interface{}) *gomock.Call

GetAPISpecsInfo indicates an expected call of GetAPISpecsInfo.

func (*MockAPIInventoryTableMockRecorder) PutAPISpec

func (mr *MockAPIInventoryTableMockRecorder) PutAPISpec(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call

PutAPISpec indicates an expected call of PutAPISpec.

type MockDatabase

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

MockDatabase is a mock of Database interface.

func NewMockDatabase

func NewMockDatabase(ctrl *gomock.Controller) *MockDatabase

NewMockDatabase creates a new mock instance.

func (*MockDatabase) APIEventsAnnotationsTable

func (m *MockDatabase) APIEventsAnnotationsTable() APIEventAnnotationTable

APIEventsAnnotationsTable mocks base method.

func (*MockDatabase) APIEventsTable

func (m *MockDatabase) APIEventsTable() APIEventsTable

APIEventsTable mocks base method.

func (*MockDatabase) APIInfoAnnotationsTable

func (m *MockDatabase) APIInfoAnnotationsTable() APIAnnotationsTable

APIInfoAnnotationsTable mocks base method.

func (*MockDatabase) APIInventoryTable

func (m *MockDatabase) APIInventoryTable() APIInventoryTable

APIInventoryTable mocks base method.

func (*MockDatabase) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDatabase) ReviewTable

func (m *MockDatabase) ReviewTable() ReviewTable

ReviewTable mocks base method.

func (*MockDatabase) TraceSamplingTable

func (m *MockDatabase) TraceSamplingTable() TraceSamplingTable

TraceSamplingTable mocks base method.

func (*MockDatabase) TraceSourcesTable

func (m *MockDatabase) TraceSourcesTable() TraceSourcesTable

TraceSourcesTable mocks base method.

type MockDatabaseMockRecorder

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

MockDatabaseMockRecorder is the mock recorder for MockDatabase.

func (*MockDatabaseMockRecorder) APIEventsAnnotationsTable

func (mr *MockDatabaseMockRecorder) APIEventsAnnotationsTable() *gomock.Call

APIEventsAnnotationsTable indicates an expected call of APIEventsAnnotationsTable.

func (*MockDatabaseMockRecorder) APIEventsTable

func (mr *MockDatabaseMockRecorder) APIEventsTable() *gomock.Call

APIEventsTable indicates an expected call of APIEventsTable.

func (*MockDatabaseMockRecorder) APIInfoAnnotationsTable

func (mr *MockDatabaseMockRecorder) APIInfoAnnotationsTable() *gomock.Call

APIInfoAnnotationsTable indicates an expected call of APIInfoAnnotationsTable.

func (*MockDatabaseMockRecorder) APIInventoryTable

func (mr *MockDatabaseMockRecorder) APIInventoryTable() *gomock.Call

APIInventoryTable indicates an expected call of APIInventoryTable.

func (*MockDatabaseMockRecorder) ReviewTable

func (mr *MockDatabaseMockRecorder) ReviewTable() *gomock.Call

ReviewTable indicates an expected call of ReviewTable.

func (*MockDatabaseMockRecorder) TraceSamplingTable

func (mr *MockDatabaseMockRecorder) TraceSamplingTable() *gomock.Call

TraceSamplingTable indicates an expected call of TraceSamplingTable.

func (*MockDatabaseMockRecorder) TraceSourcesTable

func (mr *MockDatabaseMockRecorder) TraceSourcesTable() *gomock.Call

TraceSourcesTable indicates an expected call of TraceSourcesTable.

type Review

type Review struct {
	// will be populated after inserting to DB
	ID uint `gorm:"primarykey" faker:"-"`

	Approved bool   `json:"approved,omitempty" gorm:"column:approved" faker:"-"`
	SpecKey  string `json:"specKey,omitempty" gorm:"column:spec_key" faker:"-"`
	// serialized PathToPathItem from Speculator
	PathToPathItemStr string `json:"pathToPathItemStr,omitempty" gorm:"column:path_to_path_item_str" faker:"-"`

	APIInfoID uint    `json:"apiInfoId,omitempty" gorm:"column:api_info_id" faker:"-"`
	APIInfo   APIInfo `gorm:"constraint:OnDelete:CASCADE"`
}

func (Review) TableName

func (Review) TableName() string

type ReviewTable

type ReviewTable interface {
	UpdateApprovedReview(approved bool, id uint32) error
	Create(review *Review) error
	First(dest *Review, conds ...interface{}) error
	DeleteApproved() error
}

type ReviewTableHandler

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

func (*ReviewTableHandler) Create

func (r *ReviewTableHandler) Create(review *Review) error

func (*ReviewTableHandler) DeleteApproved

func (r *ReviewTableHandler) DeleteApproved() error

func (*ReviewTableHandler) First

func (r *ReviewTableHandler) First(dest *Review, conds ...interface{}) error

func (*ReviewTableHandler) UpdateApprovedReview

func (r *ReviewTableHandler) UpdateApprovedReview(approved bool, id uint32) error

type TraceSampling

type TraceSampling struct {
	gorm.Model

	APIID         uint   `json:"api_id,omitempty" gorm:"column:api_id" faker:"-"`
	TraceSourceID uint   `json:"trace_source_id,omitempty" gorm:"column:trace_source_id" faker:"-"`
	Component     string `json:"component,omitempty" gorm:"column:component" faker:"-"`

	APIInfo     APIInfo     `gorm:"foreignKey:APIID;constraint:OnDelete:CASCADE"`
	TraceSource TraceSource `gorm:"constraint:OnDelete:CASCADE"`
}

func (TraceSampling) TableName

func (TraceSampling) TableName() string

type TraceSamplingTable

type TraceSamplingTable interface {
	AddAPIToTrace(component string, traceSourceID uint, apiID uint32) error
	GetAPIsToTrace(component string, traceSourceID uint) ([]*TraceSampling, error)
	DeleteAPIToTrace(component string, traceSourceID uint, apiID uint32) error
	DeleteAll() error
	ResetAPIsToTraceByTraceSource(component string, traceSourceID uint) error
	ResetAPIsToTraceByComponent(component string) error
	GetExternalTraceSourceID() (uint, error)
	HostsToTraceByTraceSource(component string, traceSourceID uint) ([]string, error)
	HostsToTraceByComponent(component string) (map[uint][]string, error)
}

type TraceSamplingTableHandler

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

func (*TraceSamplingTableHandler) AddAPIToTrace

func (h *TraceSamplingTableHandler) AddAPIToTrace(component string, traceSourceID uint, apiID uint32) error

func (*TraceSamplingTableHandler) DeleteAPIToTrace

func (h *TraceSamplingTableHandler) DeleteAPIToTrace(component string, traceSourceID uint, apiID uint32) error

func (*TraceSamplingTableHandler) DeleteAll

func (h *TraceSamplingTableHandler) DeleteAll() error

func (*TraceSamplingTableHandler) GetAPIsToTrace

func (h *TraceSamplingTableHandler) GetAPIsToTrace(component string, traceSourceID uint) ([]*TraceSampling, error)

func (*TraceSamplingTableHandler) GetExternalTraceSourceID

func (h *TraceSamplingTableHandler) GetExternalTraceSourceID() (uint, error)

func (*TraceSamplingTableHandler) HostsToTraceByComponent

func (h *TraceSamplingTableHandler) HostsToTraceByComponent(component string) (map[uint][]string, error)

func (*TraceSamplingTableHandler) HostsToTraceByTraceSource

func (h *TraceSamplingTableHandler) HostsToTraceByTraceSource(component string, traceSourceID uint) ([]string, error)

func (*TraceSamplingTableHandler) ResetAPIsToTraceByComponent

func (h *TraceSamplingTableHandler) ResetAPIsToTraceByComponent(component string) error

func (*TraceSamplingTableHandler) ResetAPIsToTraceByTraceSource

func (h *TraceSamplingTableHandler) ResetAPIsToTraceByTraceSource(component string, traceSourceID uint) error

type TraceSamplingWithHostAndPort

type TraceSamplingWithHostAndPort struct {
	APIID                uint
	TraceSourceID        uint
	Component            string
	Name                 string
	Port                 uint
	DestinationNamespace string
}

type TraceSource

type TraceSource struct {
	gorm.Model

	UID         uuid.UUID `json:"uid,omitempty" gorm:"column:uid;uniqueIndex;type:uuid"`
	Name        string    `json:"name,omitempty" gorm:"column:name;uniqueIndex" faker:"oneof: customer1.apigee.gw, mynicegateway"`
	Type        string    `json:"type,omitempty" gorm:"column:type" faker:"oneof: KONG, TYK, APIGEEX"`
	Description string    `json:"description,omitempty" gorm:"column:description" faker:"-"`
	Token       string    `json:"auth_token,omitempty" gorm:"column:auth_token;uniqueIndex" faker:"-"`
}

func (*TraceSource) BeforeCreate

func (source *TraceSource) BeforeCreate(tx *gorm.DB) error

type TraceSourcesTable

type TraceSourcesTable interface {
	Prepopulate() error
	CreateTraceSource(source *TraceSource) error
	GetTraceSource(uuid.UUID) (*TraceSource, error)
	GetTraceSourceFromToken(token string) (*TraceSource, error)
	GetTraceSources() ([]*TraceSource, error)
	DeleteTraceSource(uuid.UUID) error
}

type TraceSourcesTableHandler

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

func (*TraceSourcesTableHandler) CreateTraceSource

func (h *TraceSourcesTableHandler) CreateTraceSource(source *TraceSource) error

func (*TraceSourcesTableHandler) DeleteTraceSource

func (h *TraceSourcesTableHandler) DeleteTraceSource(uid uuid.UUID) error

func (*TraceSourcesTableHandler) GetTraceSource

func (h *TraceSourcesTableHandler) GetTraceSource(uid uuid.UUID) (*TraceSource, error)

func (*TraceSourcesTableHandler) GetTraceSourceFromToken

func (h *TraceSourcesTableHandler) GetTraceSourceFromToken(token string) (*TraceSource, error)

func (*TraceSourcesTableHandler) GetTraceSources

func (h *TraceSourcesTableHandler) GetTraceSources() ([]*TraceSource, error)

func (*TraceSourcesTableHandler) Prepopulate

func (h *TraceSourcesTableHandler) Prepopulate() error

Jump to

Keyboard shortcuts

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