diff --git a/internal/api/graphql/graph/model/models.go b/internal/api/graphql/graph/model/models.go index 0952c290..b3cba03d 100644 --- a/internal/api/graphql/graph/model/models.go +++ b/internal/api/graphql/graph/model/models.go @@ -219,7 +219,7 @@ func NewIssueMatchEntity(im *IssueMatchInput) entity.IssueMatch { IssueId: issueId, ComponentInstanceId: ciId, UserId: userId, - CreatedAt: createdAt, + Info: entity.Info{CreatedAt: createdAt}, } } diff --git a/internal/database/mariadb/entity.go b/internal/database/mariadb/entity.go index 5a584e6b..c1f135f4 100644 --- a/internal/database/mariadb/entity.go +++ b/internal/database/mariadb/entity.go @@ -96,9 +96,11 @@ func (ir *IssueRow) AsIssue() entity.Issue { IssueVariants: []entity.IssueVariant{}, IssueMatches: []entity.IssueMatch{}, Activity: []entity.Activity{}, - CreatedAt: GetTimeValue(ir.CreatedAt), - DeletedAt: GetTimeValue(ir.DeletedAt), - UpdatedAt: GetTimeValue(ir.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(ir.CreatedAt), + DeletedAt: GetTimeValue(ir.DeletedAt), + UpdatedAt: GetTimeValue(ir.UpdatedAt), + }, } } @@ -136,9 +138,11 @@ func (ibr *GetIssuesByRow) AsIssueWithAggregations() entity.IssueWithAggregation IssueVariants: []entity.IssueVariant{}, IssueMatches: []entity.IssueMatch{}, Activity: []entity.Activity{}, - CreatedAt: GetTimeValue(ibr.IssueRow.CreatedAt), - DeletedAt: GetTimeValue(ibr.IssueRow.DeletedAt), - UpdatedAt: GetTimeValue(ibr.IssueRow.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(ibr.IssueRow.CreatedAt), + DeletedAt: GetTimeValue(ibr.IssueRow.DeletedAt), + UpdatedAt: GetTimeValue(ibr.IssueRow.UpdatedAt), + }, }, } } @@ -152,9 +156,11 @@ func (ibr *GetIssuesByRow) AsIssue() entity.Issue { IssueVariants: []entity.IssueVariant{}, IssueMatches: []entity.IssueMatch{}, Activity: []entity.Activity{}, - CreatedAt: GetTimeValue(ibr.IssueRow.CreatedAt), - DeletedAt: GetTimeValue(ibr.IssueRow.DeletedAt), - UpdatedAt: GetTimeValue(ibr.IssueRow.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(ibr.IssueRow.CreatedAt), + DeletedAt: GetTimeValue(ibr.IssueRow.DeletedAt), + UpdatedAt: GetTimeValue(ibr.IssueRow.UpdatedAt), + }, } } @@ -208,9 +214,11 @@ func (imr IssueMatchRow) AsIssueMatch() entity.IssueMatch { RemediationDate: GetTimeValue(imr.RemediationDate), TargetRemediationDate: GetTimeValue(imr.TargetRemediationDate), Severity: entity.NewSeverity(GetStringValue(imr.Vector)), - CreatedAt: GetTimeValue(imr.CreatedAt), - DeletedAt: GetTimeValue(imr.DeletedAt), - UpdatedAt: GetTimeValue(imr.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(imr.CreatedAt), + DeletedAt: GetTimeValue(imr.DeletedAt), + UpdatedAt: GetTimeValue(imr.UpdatedAt), + }, } } @@ -259,9 +267,11 @@ func (birr *BaseIssueRepositoryRow) AsBaseIssueRepository() entity.BaseIssueRepo Url: GetStringValue(birr.Url), IssueVariants: nil, Services: nil, - CreatedAt: GetTimeValue(birr.CreatedAt), - DeletedAt: GetTimeValue(birr.DeletedAt), - UpdatedAt: GetTimeValue(birr.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(birr.CreatedAt), + DeletedAt: GetTimeValue(birr.DeletedAt), + UpdatedAt: GetTimeValue(birr.UpdatedAt), + }, } } @@ -273,9 +283,11 @@ func (barr *BaseIssueRepositoryRow) AsIssueRepository() entity.IssueRepository { Url: GetStringValue(barr.Url), IssueVariants: nil, Services: nil, - CreatedAt: GetTimeValue(barr.CreatedAt), - DeletedAt: GetTimeValue(barr.DeletedAt), - UpdatedAt: GetTimeValue(barr.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(barr.CreatedAt), + DeletedAt: GetTimeValue(barr.DeletedAt), + UpdatedAt: GetTimeValue(barr.UpdatedAt), + }, }, } } @@ -288,9 +300,11 @@ func (irr *IssueRepositoryRow) AsIssueRepository() entity.IssueRepository { Url: GetStringValue(irr.Url), IssueVariants: nil, Services: nil, - CreatedAt: GetTimeValue(irr.BaseIssueRepositoryRow.CreatedAt), - DeletedAt: GetTimeValue(irr.BaseIssueRepositoryRow.DeletedAt), - UpdatedAt: GetTimeValue(irr.BaseIssueRepositoryRow.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(irr.BaseIssueRepositoryRow.CreatedAt), + DeletedAt: GetTimeValue(irr.BaseIssueRepositoryRow.DeletedAt), + UpdatedAt: GetTimeValue(irr.BaseIssueRepositoryRow.UpdatedAt), + }, }, IssueRepositoryService: entity.IssueRepositoryService{ ServiceId: GetInt64Value(irr.ServiceId), @@ -322,9 +336,11 @@ func (ivr *IssueVariantRow) AsIssueVariant(repository *entity.IssueRepository) e Issue: nil, Severity: entity.NewSeverity(GetStringValue(ivr.Vector)), Description: GetStringValue(ivr.Description), - CreatedAt: GetTimeValue(ivr.CreatedAt), - DeletedAt: GetTimeValue(ivr.DeletedAt), - UpdatedAt: GetTimeValue(ivr.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(ivr.CreatedAt), + DeletedAt: GetTimeValue(ivr.DeletedAt), + UpdatedAt: GetTimeValue(ivr.UpdatedAt), + }, } } @@ -357,9 +373,11 @@ func (ivwr *IssueVariantWithRepository) AsIssueVariantEntry() entity.IssueVarian Issue: nil, Severity: entity.NewSeverity(GetStringValue(ivwr.Vector)), Description: GetStringValue(ivwr.Description), - CreatedAt: GetTimeValue(ivwr.IssueVariantRow.CreatedAt), - DeletedAt: GetTimeValue(ivwr.IssueVariantRow.DeletedAt), - UpdatedAt: GetTimeValue(ivwr.IssueVariantRow.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(ivwr.IssueVariantRow.CreatedAt), + DeletedAt: GetTimeValue(ivwr.IssueVariantRow.DeletedAt), + UpdatedAt: GetTimeValue(ivwr.IssueVariantRow.UpdatedAt), + }, } } @@ -374,12 +392,14 @@ type ComponentRow struct { func (cr *ComponentRow) AsComponent() entity.Component { return entity.Component{ - Id: GetInt64Value(cr.Id), - Name: GetStringValue(cr.Name), - Type: GetStringValue(cr.Type), - CreatedAt: GetTimeValue(cr.CreatedAt), - DeletedAt: GetTimeValue(cr.DeletedAt), - UpdatedAt: GetTimeValue(cr.UpdatedAt), + Id: GetInt64Value(cr.Id), + Name: GetStringValue(cr.Name), + Type: GetStringValue(cr.Type), + Info: entity.Info{ + CreatedAt: GetTimeValue(cr.CreatedAt), + DeletedAt: GetTimeValue(cr.DeletedAt), + UpdatedAt: GetTimeValue(cr.UpdatedAt), + }, } } @@ -406,9 +426,11 @@ func (cvr *ComponentVersionRow) AsComponentVersion() entity.ComponentVersion { Id: GetInt64Value(cvr.Id), Version: GetStringValue(cvr.Version), ComponentId: GetInt64Value(cvr.ComponentId), - CreatedAt: GetTimeValue(cvr.CreatedAt), - DeletedAt: GetTimeValue(cvr.DeletedAt), - UpdatedAt: GetTimeValue(cvr.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(cvr.CreatedAt), + DeletedAt: GetTimeValue(cvr.DeletedAt), + UpdatedAt: GetTimeValue(cvr.UpdatedAt), + }, } } @@ -431,11 +453,13 @@ type SupportGroupRow struct { func (sgr *SupportGroupRow) AsSupportGroup() entity.SupportGroup { return entity.SupportGroup{ - Id: GetInt64Value(sgr.Id), - Name: GetStringValue(sgr.Name), - CreatedAt: GetTimeValue(sgr.CreatedAt), - DeletedAt: GetTimeValue(sgr.DeletedAt), - UpdatedAt: GetTimeValue(sgr.UpdatedAt), + Id: GetInt64Value(sgr.Id), + Name: GetStringValue(sgr.Name), + Info: entity.Info{ + CreatedAt: GetTimeValue(sgr.CreatedAt), + DeletedAt: GetTimeValue(sgr.DeletedAt), + UpdatedAt: GetTimeValue(sgr.UpdatedAt), + }, } } @@ -466,9 +490,11 @@ func (bsr *BaseServiceRow) AsBaseService() entity.BaseService { Name: GetStringValue(bsr.Name), Owners: []entity.User{}, Activities: []entity.Activity{}, - CreatedAt: GetTimeValue(bsr.CreatedAt), - DeletedAt: GetTimeValue(bsr.DeletedAt), - UpdatedAt: GetTimeValue(bsr.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(bsr.CreatedAt), + DeletedAt: GetTimeValue(bsr.DeletedAt), + UpdatedAt: GetTimeValue(bsr.UpdatedAt), + }, } } @@ -486,9 +512,11 @@ func (sr *ServiceRow) AsService() entity.Service { Name: GetStringValue(sr.Name), Owners: []entity.User{}, Activities: []entity.Activity{}, - CreatedAt: GetTimeValue(sr.BaseServiceRow.CreatedAt), - DeletedAt: GetTimeValue(sr.BaseServiceRow.DeletedAt), - UpdatedAt: GetTimeValue(sr.BaseServiceRow.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(sr.BaseServiceRow.CreatedAt), + DeletedAt: GetTimeValue(sr.BaseServiceRow.DeletedAt), + UpdatedAt: GetTimeValue(sr.BaseServiceRow.UpdatedAt), + }, }, IssueRepositoryService: entity.IssueRepositoryService{ ServiceId: GetInt64Value(sr.ServiceId), @@ -519,9 +547,11 @@ func (ar *ActivityRow) AsActivity() entity.Activity { Status: entity.ActivityStatusValue(GetStringValue(ar.Status)), Issues: []entity.Issue{}, Evidences: []entity.Evidence{}, - CreatedAt: GetTimeValue(ar.CreatedAt), - DeletedAt: GetTimeValue(ar.DeletedAt), - UpdatedAt: GetTimeValue(ar.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(ar.CreatedAt), + DeletedAt: GetTimeValue(ar.DeletedAt), + UpdatedAt: GetTimeValue(ar.UpdatedAt), + }, } } @@ -553,9 +583,11 @@ func (cir *ComponentInstanceRow) AsComponentInstance() entity.ComponentInstance ComponentVersionId: GetInt64Value(cir.ComponentVersionId), Service: nil, ServiceId: GetInt64Value(cir.ServiceId), - CreatedAt: GetTimeValue(cir.CreatedAt), - DeletedAt: GetTimeValue(cir.DeletedAt), - UpdatedAt: GetTimeValue(cir.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(cir.CreatedAt), + DeletedAt: GetTimeValue(cir.DeletedAt), + UpdatedAt: GetTimeValue(cir.UpdatedAt), + }, } } @@ -586,9 +618,11 @@ func (ur *UserRow) AsUser() entity.User { Name: GetStringValue(ur.Name), UniqueUserID: GetStringValue(ur.UniqueUserID), Type: GetUserTypeValue(ur.Type), - CreatedAt: GetTimeValue(ur.CreatedAt), - DeletedAt: GetTimeValue(ur.DeletedAt), - UpdatedAt: GetTimeValue(ur.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(ur.CreatedAt), + DeletedAt: GetTimeValue(ur.DeletedAt), + UpdatedAt: GetTimeValue(ur.UpdatedAt), + }, } } @@ -629,9 +663,11 @@ func (er *EvidenceRow) AsEvidence() entity.Evidence { UserId: GetInt64Value(er.UserId), Activity: nil, ActivityId: GetInt64Value(er.ActivityId), - CreatedAt: GetTimeValue(er.CreatedAt), - DeletedAt: GetTimeValue(er.DeletedAt), - UpdatedAt: GetTimeValue(er.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(er.CreatedAt), + DeletedAt: GetTimeValue(er.DeletedAt), + UpdatedAt: GetTimeValue(er.UpdatedAt), + }, } } @@ -665,9 +701,11 @@ func (imcr *IssueMatchChangeRow) AsIssueMatchChange() entity.IssueMatchChange { IssueMatchId: GetInt64Value(imcr.IssueMatchId), ActivityId: GetInt64Value(imcr.ActivityId), Action: GetStringValue(imcr.Action), - CreatedAt: GetTimeValue(imcr.CreatedAt), - DeletedAt: GetTimeValue(imcr.DeletedAt), - UpdatedAt: GetTimeValue(imcr.UpdatedAt), + Info: entity.Info{ + CreatedAt: GetTimeValue(imcr.CreatedAt), + DeletedAt: GetTimeValue(imcr.DeletedAt), + UpdatedAt: GetTimeValue(imcr.UpdatedAt), + }, } } diff --git a/internal/database/mariadb/internal/mocks/mock_Database.go b/internal/database/mariadb/internal/mocks/mock_Database.go index 94837644..9d742550 100644 --- a/internal/database/mariadb/internal/mocks/mock_Database.go +++ b/internal/database/mariadb/internal/mocks/mock_Database.go @@ -6,8 +6,8 @@ package mocks import ( - mock "github.com/stretchr/testify/mock" entity "github.com/cloudoperators/heureka/internal/entity" + mock "github.com/stretchr/testify/mock" ) // MockDatabase is an autogenerated mock type for the Database type diff --git a/internal/database/mariadb/internal/mocks/mock_Heureka.go b/internal/database/mariadb/internal/mocks/mock_Heureka.go index 89974edc..d5b9bfe8 100644 --- a/internal/database/mariadb/internal/mocks/mock_Heureka.go +++ b/internal/database/mariadb/internal/mocks/mock_Heureka.go @@ -6,8 +6,8 @@ package mocks import ( - mock "github.com/stretchr/testify/mock" entity "github.com/cloudoperators/heureka/internal/entity" + mock "github.com/stretchr/testify/mock" ) // MockHeureka is an autogenerated mock type for the Heureka type diff --git a/internal/entity/activity.go b/internal/entity/activity.go index d5a4e4a6..d637ec6c 100644 --- a/internal/entity/activity.go +++ b/internal/entity/activity.go @@ -3,8 +3,6 @@ package entity -import "time" - type ActivityStatusValue string const ( @@ -36,14 +34,12 @@ var AllActivityStatusValues = []string{ } type Activity struct { + Info Id int64 `json:"id"` Status ActivityStatusValue `json:"status"` Service *Service `json:"service,omitempty"` Issues []Issue `json:"issues,omitempty"` Evidences []Evidence `json:"evidences,omitempty"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` } func (a *Activity) GetId() int64 { @@ -51,17 +47,17 @@ func (a *Activity) GetId() int64 { } type ActivityHasIssue struct { - ActivityId int64 `json:"activity_id"` - IssueId int64 `json:"issue_id"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` + Info + ActivityId int64 `json:"activity_id"` + IssueId int64 `json:"issue_id"` } type ActivityAggregations struct { + Info } type ActivityFilter struct { + Info Paginated Status []*string `json:"status"` ServiceName []*string `json:"service_name"` diff --git a/internal/entity/common.go b/internal/entity/common.go index 92f9aa27..be47aa81 100644 --- a/internal/entity/common.go +++ b/internal/entity/common.go @@ -17,10 +17,13 @@ import ( type HeurekaEntity interface { Activity | + ActivityAggregations | ActivityHasIssue | IssueVariant | + IssueVariantAggregations | BaseIssueRepository | IssueRepository | + IssueRepositoryAggregations | ResultList | ListOptions | PageInfo | @@ -28,24 +31,30 @@ type HeurekaEntity interface { Severity | Cvss | Component | - ComponentInstanceAggregations | + ComponentAggregations | ComponentInstance | + ComponentInstanceAggregations | ComponentVersion | + ComponentVersionAggregations | Evidence | + EvidenceAggregations | BaseService | Service | ServiceAggregations | SupportGroup | + SupportGroupAggregations | SupportGroupService | SupportGroupUser | User | + UserAggregations | IssueWithAggregations | IssueAggregations | Issue | IssueMatch | IssueMatchChange | HeurekaFilter | - IssueCount + IssueCount | + IssueTypeCounts } type HeurekaFilter interface { @@ -62,7 +71,8 @@ type HeurekaFilter interface { EvidenceFilter | ComponentFilter | ComponentVersionFilter | - IssueRepositoryFilter + IssueRepositoryFilter | + SeverityFilter } type HasCursor interface { @@ -83,6 +93,7 @@ type ResultList struct { } type ListOptions struct { + Info ShowTotalCount bool `json:"show_total_count"` ShowPageInfo bool `json:"show_page_info"` IncludeAggregations bool `json:"include_aggregations"` @@ -97,6 +108,7 @@ func NewListOptions() *ListOptions { } type PageInfo struct { + Info HasNextPage *bool `json:"has_next_page,omitempty"` HasPreviousPage *bool `json:"has_previous_page,omitempty"` IsValidPage *bool `json:"is_valid_page,omitempty"` @@ -108,6 +120,7 @@ type PageInfo struct { } type Page struct { + Info After *string `json:"after,omitempty"` PageNumber *int `json:"page_number,omitempty"` IsCurrent bool `json:"is_current,omitempty"` @@ -121,11 +134,13 @@ type List[T interface{}] struct { } type TimeFilter struct { + Info After time.Time `json:"after"` Before time.Time `json:"before"` } type Paginated struct { + Info First *int `json:"first"` After *int64 `json:"from"` } @@ -137,6 +152,7 @@ func MaxPaginated() Paginated { } type Severity struct { + Info Value string Score float64 Cvss Cvss @@ -178,8 +194,17 @@ func NewSeverity(url string) Severity { } type Cvss struct { + Info Vector string Base *metric.Base Temporal *metric.Temporal Environmental *metric.Environmental } + +type Info struct { + CreatedAt time.Time `json:"created_at"` + CreatedBy string `json:"created_by"` + UpdatedAt time.Time `json:"updated_at"` + UpdatedBy string `json:"updated_by"` + DeletedAt time.Time `json:"deleted_at,omitempty"` +} diff --git a/internal/entity/component.go b/internal/entity/component.go index 28204808..17efa12a 100644 --- a/internal/entity/component.go +++ b/internal/entity/component.go @@ -3,15 +3,11 @@ package entity -import "time" - type Component struct { - Id int64 `json:"id"` - Name string `json:"name"` - Type string `json:"type"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` + Info + Id int64 `json:"id"` + Name string `json:"name"` + Type string `json:"type"` } type ComponentResult struct { @@ -21,6 +17,7 @@ type ComponentResult struct { } type ComponentFilter struct { + Info Paginated Name []*string `json:"name"` Id []*int64 `json:"id"` diff --git a/internal/entity/component_instance.go b/internal/entity/component_instance.go index 0851a080..36fd81f4 100644 --- a/internal/entity/component_instance.go +++ b/internal/entity/component_instance.go @@ -3,9 +3,8 @@ package entity -import "time" - type ComponentInstanceFilter struct { + Info Paginated IssueMatchId []*int64 `json:"issue_match_id"` ServiceId []*int64 `json:"service_id"` @@ -13,7 +12,9 @@ type ComponentInstanceFilter struct { Id []*int64 `json:"id"` } -type ComponentInstanceAggregations struct{} +type ComponentInstanceAggregations struct { + Info +} type ComponentInstanceResult struct { WithCursor @@ -22,6 +23,7 @@ type ComponentInstanceResult struct { } type ComponentInstance struct { + Info Id int64 `json:"id"` CCRN string `json:"ccrn"` Count int16 `json:"count"` @@ -29,7 +31,4 @@ type ComponentInstance struct { ComponentVersionId int64 `db:"componentinstance_component_version_id"` Service *Service `json:"service,omitempty"` ServiceId int64 `db:"componentinstance_service_id"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` } diff --git a/internal/entity/component_version.go b/internal/entity/component_version.go index 9d88b2f2..768fcb1d 100644 --- a/internal/entity/component_version.go +++ b/internal/entity/component_version.go @@ -3,9 +3,8 @@ package entity -import "time" - type ComponentVersionFilter struct { + Info Paginated Id []*int64 `json:"id"` IssueId []*int64 `json:"issue_id"` @@ -13,7 +12,9 @@ type ComponentVersionFilter struct { Version []*string `json:"version"` } -type ComponentVersionAggregations struct{} +type ComponentVersionAggregations struct { + Info +} type ComponentVersionResult struct { WithCursor @@ -22,13 +23,11 @@ type ComponentVersionResult struct { } type ComponentVersion struct { + Info Id int64 `json:"id"` Version string `json:"version"` Component *Component `json:"component,omitempty"` ComponentId int64 `db:"componentversion_component_id"` ComponentInstances []ComponentInstance `json:"component_instances,omitempty"` Issues []Issue `json:"issues,omitempty"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` } diff --git a/internal/entity/evidence.go b/internal/entity/evidence.go index a4e0a0e0..a708ef6b 100644 --- a/internal/entity/evidence.go +++ b/internal/entity/evidence.go @@ -42,6 +42,7 @@ var AllEvidenceTypeValues = []string{ } type Evidence struct { + Info Id int64 `json:"id"` Description string `json:"description"` Type EvidenceType `json:"type"` @@ -51,19 +52,19 @@ type Evidence struct { UserId int64 `db:"evidence_author_id"` Activity *Activity `json:"activity,omitempty"` ActivityId int64 `db:"evidence_activity_id"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` } type EvidenceFilter struct { + Info Paginated Id []*int64 `json:"id"` ActivityId []*int64 `json:"activity_id"` IssueMatchId []*int64 `json:"issue_match_id"` UserId []*int64 `json:"user_id"` } -type EvidenceAggregations struct{} +type EvidenceAggregations struct { + Info +} type EvidenceResult struct { WithCursor diff --git a/internal/entity/issue.go b/internal/entity/issue.go index 6b114872..7eb80503 100644 --- a/internal/entity/issue.go +++ b/internal/entity/issue.go @@ -8,6 +8,7 @@ import ( ) type IssueWithAggregations struct { + Info IssueAggregations Issue } @@ -50,6 +51,7 @@ type IssueResult struct { } type IssueFilter struct { + Info Paginated PrimaryName []*string `json:"primary_name"` ServiceName []*string `json:"service_name"` @@ -66,6 +68,7 @@ type IssueFilter struct { } type IssueAggregations struct { + Info Activites int64 IssueMatches int64 AffectedServices int64 @@ -76,6 +79,7 @@ type IssueAggregations struct { } type Issue struct { + Info Id int64 `json:"id"` Type IssueType `json:"type"` PrimaryName string `json:"primary_name"` @@ -84,17 +88,16 @@ type Issue struct { IssueMatches []IssueMatch `json:"issue_matches,omitempty"` ComponentVersions []ComponentVersion `json:"component_versions,omitempty"` Activity []Activity `json:"activity,omitempty"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_lsat"` } type IssueCount struct { + Info Count int64 `json:"count"` Type IssueType `json:"type"` } type IssueTypeCounts struct { + Info VulnerabilityCount int64 `json:"vulnerability_count"` PolicyViolationCount int64 `json:"policy_violation_count"` SecurityEventCount int64 `json:"security_event_count"` diff --git a/internal/entity/issue_match.go b/internal/entity/issue_match.go index d79c8a83..e5d95609 100644 --- a/internal/entity/issue_match.go +++ b/internal/entity/issue_match.go @@ -39,6 +39,7 @@ var AllIssueMatchStatusValues = []string{ } type IssueMatch struct { + Info Id int64 `json:"id"` Status IssueMatchStatusValue `json:"status"` User *User `json:"user,omitempty"` @@ -51,12 +52,10 @@ type IssueMatch struct { IssueId int64 `json:"issue_id"` RemediationDate time.Time `json:"remediation_date"` TargetRemediationDate time.Time `json:"target_remediation_date"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` } type IssueMatchFilter struct { + Info Paginated Id []*int64 `json:"id"` AffectedServiceName []*string `json:"affected_service_name"` diff --git a/internal/entity/issue_match_change.go b/internal/entity/issue_match_change.go index 416b029a..ea66f9db 100644 --- a/internal/entity/issue_match_change.go +++ b/internal/entity/issue_match_change.go @@ -3,8 +3,6 @@ package entity -import "time" - type IssueMatchChangeAction string const ( @@ -32,18 +30,17 @@ var AllIssueMatchChangeActions = []string{ } type IssueMatchChange struct { + Info Id int64 `json:"id"` ActivityId int64 `json:"activity_id"` Activity *Activity IssueMatchId int64 `json:"issue_match_id"` IssueMatch *IssueMatch - Action string `json:"action"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at"` - UpdatedAt time.Time `json:"updated_at"` + Action string `json:"action"` } type IssueMatchChangeFilter struct { + Info Paginated Id []*int64 `json:"id"` ActivityId []*int64 `json:"activity_id"` diff --git a/internal/entity/issue_repository.go b/internal/entity/issue_repository.go index 0be984f5..2577d96f 100644 --- a/internal/entity/issue_repository.go +++ b/internal/entity/issue_repository.go @@ -3,20 +3,17 @@ package entity -import "time" - type BaseIssueRepository struct { + Info Id int64 `json:"id"` Name string `json:"name"` Url string `json:"url"` IssueVariants []IssueVariant `json:"issue_variants,omitempty"` Services []Service `json:"services,omitempty"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` } type IssueRepositoryFilter struct { + Info Paginated Id []*int64 `json:"id"` ServiceId []*int64 `json:"service_id"` @@ -38,9 +35,11 @@ func NewIssueRepositoryFilter() *IssueRepositoryFilter { } type IssueRepositoryAggregations struct { + Info } type IssueRepository struct { + Info BaseIssueRepository IssueRepositoryService } diff --git a/internal/entity/issue_repository_service.go b/internal/entity/issue_repository_service.go index fddbc449..83b40703 100644 --- a/internal/entity/issue_repository_service.go +++ b/internal/entity/issue_repository_service.go @@ -3,13 +3,9 @@ package entity -import "time" - type IssueRepositoryService struct { - ServiceId int64 `json:"service_id"` - IssueRepositoryId int64 `json:"issue_repository_id"` - Priority int64 `json:"priority"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` + Info + ServiceId int64 `json:"service_id"` + IssueRepositoryId int64 `json:"issue_repository_id"` + Priority int64 `json:"priority"` } diff --git a/internal/entity/issue_variant.go b/internal/entity/issue_variant.go index e7516a07..745ab991 100644 --- a/internal/entity/issue_variant.go +++ b/internal/entity/issue_variant.go @@ -3,9 +3,8 @@ package entity -import "time" - type IssueVariant struct { + Info Id int64 `json:"id"` IssueRepositoryId int64 `json:"issue_repository_id"` IssueRepository *IssueRepository `json:"issue_repository"` @@ -14,12 +13,10 @@ type IssueVariant struct { Issue *Issue `json:"issue"` Severity Severity `json:"severity"` Description string `json:"description"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` } type IssueVariantFilter struct { + Info Paginated Id []*int64 `json:"id"` SecondaryName []*string `json:"secondary_name"` @@ -45,6 +42,7 @@ func NewIssueVariantFilter() *IssueVariantFilter { } type IssueVariantAggregations struct { + Info } type IssueVariantResult struct { diff --git a/internal/entity/service.go b/internal/entity/service.go index cb7c7e67..ee62309a 100644 --- a/internal/entity/service.go +++ b/internal/entity/service.go @@ -3,9 +3,8 @@ package entity -import "time" - type BaseService struct { + Info Id int64 `json:"id"` Name string `json:"name"` SupportGroup *SupportGroup `json:"support_group,omitempty"` @@ -13,15 +12,14 @@ type BaseService struct { Owners []User `json:"owners,omitempty"` Activities []Activity `json:"activities,omitempty"` Priority int64 `json:"priority"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` } type ServiceAggregations struct { + Info } type ServiceFilter struct { + Info Paginated SupportGroupName []*string `json:"support_group_name"` Id []*int64 `json:"id"` @@ -36,6 +34,7 @@ type ServiceFilter struct { } type Service struct { + Info BaseService IssueRepositoryService } diff --git a/internal/entity/severity.go b/internal/entity/severity.go index ca9e7541..bc9a7b26 100644 --- a/internal/entity/severity.go +++ b/internal/entity/severity.go @@ -4,6 +4,7 @@ package entity type SeverityFilter struct { + Info IssueMatchId []*int64 `json:"issue_match_id"` IssueId []*int64 `json:"issue_id"` } diff --git a/internal/entity/support_group.go b/internal/entity/support_group.go index ca280db0..7a94d65e 100644 --- a/internal/entity/support_group.go +++ b/internal/entity/support_group.go @@ -3,17 +3,14 @@ package entity -import "time" - type SupportGroup struct { - Id int64 `json:"id"` - Name string `json:"name"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` + Info + Id int64 `json:"id"` + Name string `json:"name"` } type SupportGroupFilter struct { + Info Paginated Id []*int64 `json:"id"` ServiceId []*int64 `json:"service_id"` @@ -22,6 +19,7 @@ type SupportGroupFilter struct { } type SupportGroupAggregations struct { + Info } type SupportGroupResult struct { diff --git a/internal/entity/support_group_service.go b/internal/entity/support_group_service.go index 1e0e42c4..af070b4f 100644 --- a/internal/entity/support_group_service.go +++ b/internal/entity/support_group_service.go @@ -3,12 +3,8 @@ package entity -import "time" - type SupportGroupService struct { - SupportGroupId int64 `json:"support_group_id"` - ServiceId int64 `json:"service_id"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` + Info + SupportGroupId int64 `json:"support_group_id"` + ServiceId int64 `json:"service_id"` } diff --git a/internal/entity/support_group_user.go b/internal/entity/support_group_user.go index e35ad945..2c781add 100644 --- a/internal/entity/support_group_user.go +++ b/internal/entity/support_group_user.go @@ -3,12 +3,8 @@ package entity -import "time" - type SupportGroupUser struct { - SupportGroupId int64 `json:"support_group_id"` - UserId int64 `json:"user_id"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` + Info + SupportGroupId int64 `json:"support_group_id"` + UserId int64 `json:"user_id"` } diff --git a/internal/entity/test/activity.go b/internal/entity/test/activity.go index a182335b..4df12e1e 100644 --- a/internal/entity/test/activity.go +++ b/internal/entity/test/activity.go @@ -15,9 +15,11 @@ func NewFakeActivityEntity() entity.Activity { Issues: nil, Evidences: nil, Service: nil, - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/component.go b/internal/entity/test/component.go index 3b12ede3..fcac3f6b 100644 --- a/internal/entity/test/component.go +++ b/internal/entity/test/component.go @@ -10,12 +10,14 @@ import ( func NewFakeComponentEntity() entity.Component { return entity.Component{ - Id: int64(gofakeit.Number(1, 10000000)), - Name: gofakeit.Name(), - Type: gofakeit.Word(), - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Id: int64(gofakeit.Number(1, 10000000)), + Name: gofakeit.Name(), + Type: gofakeit.Word(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/component_instance.go b/internal/entity/test/component_instance.go index 217f25cc..12052b5f 100644 --- a/internal/entity/test/component_instance.go +++ b/internal/entity/test/component_instance.go @@ -17,9 +17,11 @@ func NewFakeComponentInstanceEntity() entity.ComponentInstance { ComponentVersionId: int64(gofakeit.Number(1, 10000000)), Service: nil, ServiceId: int64(gofakeit.Number(1, 10000000)), - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/component_version.go b/internal/entity/test/component_version.go index a44b32a3..97848fdf 100644 --- a/internal/entity/test/component_version.go +++ b/internal/entity/test/component_version.go @@ -15,9 +15,11 @@ func NewFakeComponentVersionEntity() entity.ComponentVersion { ComponentId: 0, ComponentInstances: nil, Issues: nil, - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/evidence.go b/internal/entity/test/evidence.go index d0c561b8..4a1380a8 100644 --- a/internal/entity/test/evidence.go +++ b/internal/entity/test/evidence.go @@ -19,9 +19,11 @@ func NewFakeEvidenceEntity() entity.Evidence { RaaEnd: gofakeit.Date(), Type: entity.NewEvidenceTypeValue(t), Severity: severity, - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/issue.go b/internal/entity/test/issue.go index 705fd9ff..a6053737 100644 --- a/internal/entity/test/issue.go +++ b/internal/entity/test/issue.go @@ -22,9 +22,11 @@ func NewFakeIssueEntity() entity.Issue { IssueMatches: nil, ComponentVersions: nil, Activity: nil, - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/issue_match.go b/internal/entity/test/issue_match.go index e0b839d0..a62ec3a8 100644 --- a/internal/entity/test/issue_match.go +++ b/internal/entity/test/issue_match.go @@ -25,9 +25,11 @@ func NewFakeIssueMatch() entity.IssueMatch { Issue: nil, RemediationDate: gofakeit.Date(), TargetRemediationDate: gofakeit.Date(), - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/issue_match_change.go b/internal/entity/test/issue_match_change.go index ea11442a..83236092 100644 --- a/internal/entity/test/issue_match_change.go +++ b/internal/entity/test/issue_match_change.go @@ -15,9 +15,11 @@ func NewFakeIssueMatchChange() entity.IssueMatchChange { Action: gofakeit.RandomString(actions), IssueMatch: nil, Activity: nil, - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/issue_repository.go b/internal/entity/test/issue_repository.go index f61af12b..a3511a01 100644 --- a/internal/entity/test/issue_repository.go +++ b/internal/entity/test/issue_repository.go @@ -11,12 +11,14 @@ import ( func NewFakeIssueRepositoryEntity() entity.IssueRepository { return entity.IssueRepository{ BaseIssueRepository: entity.BaseIssueRepository{ - Id: int64(gofakeit.Number(1, 10000000)), - Name: gofakeit.Noun(), - Url: gofakeit.URL(), - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Id: int64(gofakeit.Number(1, 10000000)), + Name: gofakeit.Noun(), + Url: gofakeit.URL(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, }, IssueRepositoryService: entity.IssueRepositoryService{ Priority: int64(gofakeit.Number(1, 10)), diff --git a/internal/entity/test/issue_variant.go b/internal/entity/test/issue_variant.go index 0a36a034..22df8d29 100644 --- a/internal/entity/test/issue_variant.go +++ b/internal/entity/test/issue_variant.go @@ -21,9 +21,11 @@ func NewFakeIssueVariantEntity() entity.IssueVariant { Issue: nil, IssueRepositoryId: 0, IssueRepository: nil, - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/service.go b/internal/entity/test/service.go index fb695bcc..6a6aabb3 100644 --- a/internal/entity/test/service.go +++ b/internal/entity/test/service.go @@ -16,9 +16,11 @@ func NewFakeServiceEntity() entity.Service { SupportGroup: nil, Activities: nil, Owners: nil, - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, }, } } diff --git a/internal/entity/test/support_group.go b/internal/entity/test/support_group.go index fc72b935..9a6d6b02 100644 --- a/internal/entity/test/support_group.go +++ b/internal/entity/test/support_group.go @@ -10,11 +10,13 @@ import ( func NewFakeSupportGroupEntity() entity.SupportGroup { return entity.SupportGroup{ - Id: int64(gofakeit.Number(1, 10000000)), - Name: gofakeit.AppName(), - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Id: int64(gofakeit.Number(1, 10000000)), + Name: gofakeit.AppName(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/test/user.go b/internal/entity/test/user.go index c06d95af..eb25ce79 100644 --- a/internal/entity/test/user.go +++ b/internal/entity/test/user.go @@ -17,9 +17,11 @@ func NewFakeUserEntity() entity.User { Name: gofakeit.Name(), UniqueUserID: uniqueUserId, Type: entity.HumanUserType, - CreatedAt: gofakeit.Date(), - DeletedAt: gofakeit.Date(), - UpdatedAt: gofakeit.Date(), + Info: entity.Info{ + CreatedAt: gofakeit.Date(), + DeletedAt: gofakeit.Date(), + UpdatedAt: gofakeit.Date(), + }, } } diff --git a/internal/entity/user.go b/internal/entity/user.go index 324a7782..77c7a34f 100644 --- a/internal/entity/user.go +++ b/internal/entity/user.go @@ -3,8 +3,6 @@ package entity -import "time" - type UserType int const ( @@ -14,16 +12,15 @@ const ( ) type User struct { - Id int64 `json:"id"` - Name string `json:"name"` - UniqueUserID string `json:"uniqueUserId"` - Type UserType `json:"type"` - CreatedAt time.Time `json:"created_at"` - DeletedAt time.Time `json:"deleted_at,omitempty"` - UpdatedAt time.Time `json:"updated_at"` + Info + Id int64 `json:"id"` + Name string `json:"name"` + UniqueUserID string `json:"uniqueUserId"` + Type UserType `json:"type"` } type UserFilter struct { + Info Paginated Name []*string `json:"name"` UniqueUserID []*string `json:"uniqueUserId"` @@ -34,6 +31,7 @@ type UserFilter struct { } type UserAggregations struct { + Info } type UserResult struct {