updates
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-14 10:07:06 +11:00
parent aa4567d7c1
commit 7b600b2359
5 changed files with 284 additions and 124 deletions

View File

@@ -9,70 +9,77 @@ import (
) )
type Event struct { type Event struct {
Eid int64 Eid int64 `db:"Eid" json:"Eid"`
CloudId string CloudId string `db:"CloudId" json:"CloudId"`
Source string Source string `db:"Source" json:"Source"`
EventTime sql.NullInt64 EventTime sql.NullInt64 `db:"EventTime" json:"EventTime"`
ChainId string ChainId string `db:"ChainId" json:"ChainId"`
VmId sql.NullString VmId sql.NullString `db:"VmId" json:"VmId"`
EventKey sql.NullString EventKey sql.NullString `db:"EventKey" json:"EventKey"`
DatacenterName sql.NullString DatacenterName sql.NullString `db:"DatacenterName" json:"DatacenterName"`
ComputeResourceName sql.NullString ComputeResourceName sql.NullString `db:"ComputeResourceName" json:"ComputeResourceName"`
UserName sql.NullString UserName sql.NullString `db:"UserName" json:"UserName"`
Processed int64 Processed int64 `db:"Processed" json:"Processed"`
DatacenterId sql.NullString DatacenterId sql.NullString `db:"DatacenterId" json:"DatacenterId"`
ComputeResourceId sql.NullString ComputeResourceId sql.NullString `db:"ComputeResourceId" json:"ComputeResourceId"`
VmName sql.NullString VmName sql.NullString `db:"VmName" json:"VmName"`
EventType sql.NullString EventType sql.NullString `db:"EventType" json:"EventType"`
} }
type Inventory struct { type Inventory struct {
Iid int64 Iid int64 `db:"Iid" json:"Iid"`
Name string Name string `db:"Name" json:"Name"`
Vcenter string Vcenter string `db:"Vcenter" json:"Vcenter"`
VmId sql.NullString VmId sql.NullString `db:"VmId" json:"VmId"`
EventKey sql.NullString EventKey sql.NullString `db:"EventKey" json:"EventKey"`
CloudId sql.NullString CloudId sql.NullString `db:"CloudId" json:"CloudId"`
CreationTime sql.NullInt64 CreationTime sql.NullInt64 `db:"CreationTime" json:"CreationTime"`
DeletionTime sql.NullInt64 DeletionTime sql.NullInt64 `db:"DeletionTime" json:"DeletionTime"`
ResourcePool sql.NullString ResourcePool sql.NullString `db:"ResourcePool" json:"ResourcePool"`
VmType sql.NullString VmType sql.NullString `db:"VmType" json:"VmType"`
Datacenter sql.NullString Datacenter sql.NullString `db:"Datacenter" json:"Datacenter"`
Cluster sql.NullString Cluster sql.NullString `db:"Cluster" json:"Cluster"`
Folder sql.NullString Folder sql.NullString `db:"Folder" json:"Folder"`
ProvisionedDisk sql.NullFloat64 ProvisionedDisk sql.NullFloat64 `db:"ProvisionedDisk" json:"ProvisionedDisk"`
InitialVcpus sql.NullInt64 InitialVcpus sql.NullInt64 `db:"InitialVcpus" json:"InitialVcpus"`
InitialRam sql.NullInt64 InitialRam sql.NullInt64 `db:"InitialRam" json:"InitialRam"`
IsTemplate interface{} IsTemplate interface{} `db:"IsTemplate" json:"IsTemplate"`
PoweredOn interface{} PoweredOn interface{} `db:"PoweredOn" json:"PoweredOn"`
SrmPlaceholder interface{} SrmPlaceholder interface{} `db:"SrmPlaceholder" json:"SrmPlaceholder"`
VmUuid sql.NullString VmUuid sql.NullString `db:"VmUuid" json:"VmUuid"`
} }
type InventoryHistory struct { type InventoryHistory struct {
Hid int64 Hid int64 `db:"Hid" json:"Hid"`
InventoryId sql.NullInt64 InventoryId sql.NullInt64 `db:"InventoryId" json:"InventoryId"`
ReportDate sql.NullInt64 ReportDate sql.NullInt64 `db:"ReportDate" json:"ReportDate"`
UpdateTime sql.NullInt64 UpdateTime sql.NullInt64 `db:"UpdateTime" json:"UpdateTime"`
PreviousVcpus sql.NullInt64 PreviousVcpus sql.NullInt64 `db:"PreviousVcpus" json:"PreviousVcpus"`
PreviousRam sql.NullInt64 PreviousRam sql.NullInt64 `db:"PreviousRam" json:"PreviousRam"`
PreviousResourcePool sql.NullString PreviousResourcePool sql.NullString `db:"PreviousResourcePool" json:"PreviousResourcePool"`
PreviousProvisionedDisk sql.NullFloat64 PreviousProvisionedDisk sql.NullFloat64 `db:"PreviousProvisionedDisk" json:"PreviousProvisionedDisk"`
}
type SnapshotRegistry struct {
ID int64 `db:"id" json:"id"`
SnapshotType string `db:"snapshot_type" json:"snapshot_type"`
TableName string `db:"table_name" json:"table_name"`
SnapshotTime int64 `db:"snapshot_time" json:"snapshot_time"`
} }
type Update struct { type Update struct {
Uid int64 Uid int64 `db:"Uid" json:"Uid"`
InventoryId sql.NullInt64 InventoryId sql.NullInt64 `db:"InventoryId" json:"InventoryId"`
UpdateTime sql.NullInt64 UpdateTime sql.NullInt64 `db:"UpdateTime" json:"UpdateTime"`
UpdateType string UpdateType string `db:"UpdateType" json:"UpdateType"`
NewVcpus sql.NullInt64 NewVcpus sql.NullInt64 `db:"NewVcpus" json:"NewVcpus"`
NewRam sql.NullInt64 NewRam sql.NullInt64 `db:"NewRam" json:"NewRam"`
NewResourcePool sql.NullString NewResourcePool sql.NullString `db:"NewResourcePool" json:"NewResourcePool"`
EventKey sql.NullString EventKey sql.NullString `db:"EventKey" json:"EventKey"`
EventId sql.NullString EventId sql.NullString `db:"EventId" json:"EventId"`
NewProvisionedDisk sql.NullFloat64 NewProvisionedDisk sql.NullFloat64 `db:"NewProvisionedDisk" json:"NewProvisionedDisk"`
UserName sql.NullString UserName sql.NullString `db:"UserName" json:"UserName"`
PlaceholderChange sql.NullString PlaceholderChange sql.NullString `db:"PlaceholderChange" json:"PlaceholderChange"`
Name sql.NullString Name sql.NullString `db:"Name" json:"Name"`
RawChangeString []byte RawChangeString []byte `db:"RawChangeString" json:"RawChangeString"`
} }

View File

@@ -17,8 +17,8 @@ RETURNING Uid, InventoryId, UpdateTime, UpdateType, NewVcpus, NewRam, NewResourc
` `
type CleanupUpdatesParams struct { type CleanupUpdatesParams struct {
UpdateType string UpdateType string `db:"updateType" json:"updateType"`
UpdateTime sql.NullInt64 UpdateTime sql.NullInt64 `db:"updateTime" json:"updateTime"`
} }
func (q *Queries) CleanupUpdates(ctx context.Context, arg CleanupUpdatesParams) error { func (q *Queries) CleanupUpdates(ctx context.Context, arg CleanupUpdatesParams) error {
@@ -47,19 +47,19 @@ RETURNING Eid, CloudId, Source, EventTime, ChainId, VmId, EventKey, DatacenterNa
` `
type CreateEventParams struct { type CreateEventParams struct {
CloudId string CloudId string `db:"CloudId" json:"CloudId"`
Source string Source string `db:"Source" json:"Source"`
EventTime sql.NullInt64 EventTime sql.NullInt64 `db:"EventTime" json:"EventTime"`
ChainId string ChainId string `db:"ChainId" json:"ChainId"`
VmId sql.NullString VmId sql.NullString `db:"VmId" json:"VmId"`
VmName sql.NullString VmName sql.NullString `db:"VmName" json:"VmName"`
EventType sql.NullString EventType sql.NullString `db:"EventType" json:"EventType"`
EventKey sql.NullString EventKey sql.NullString `db:"EventKey" json:"EventKey"`
DatacenterId sql.NullString DatacenterId sql.NullString `db:"DatacenterId" json:"DatacenterId"`
DatacenterName sql.NullString DatacenterName sql.NullString `db:"DatacenterName" json:"DatacenterName"`
ComputeResourceId sql.NullString ComputeResourceId sql.NullString `db:"ComputeResourceId" json:"ComputeResourceId"`
ComputeResourceName sql.NullString ComputeResourceName sql.NullString `db:"ComputeResourceName" json:"ComputeResourceName"`
UserName sql.NullString UserName sql.NullString `db:"UserName" json:"UserName"`
} }
func (q *Queries) CreateEvent(ctx context.Context, arg CreateEventParams) (Event, error) { func (q *Queries) CreateEvent(ctx context.Context, arg CreateEventParams) (Event, error) {
@@ -109,24 +109,24 @@ RETURNING Iid, Name, Vcenter, VmId, EventKey, CloudId, CreationTime, DeletionTim
` `
type CreateInventoryParams struct { type CreateInventoryParams struct {
Name string Name string `db:"Name" json:"Name"`
Vcenter string Vcenter string `db:"Vcenter" json:"Vcenter"`
VmId sql.NullString VmId sql.NullString `db:"VmId" json:"VmId"`
VmUuid sql.NullString VmUuid sql.NullString `db:"VmUuid" json:"VmUuid"`
EventKey sql.NullString EventKey sql.NullString `db:"EventKey" json:"EventKey"`
CloudId sql.NullString CloudId sql.NullString `db:"CloudId" json:"CloudId"`
CreationTime sql.NullInt64 CreationTime sql.NullInt64 `db:"CreationTime" json:"CreationTime"`
ResourcePool sql.NullString ResourcePool sql.NullString `db:"ResourcePool" json:"ResourcePool"`
VmType sql.NullString VmType sql.NullString `db:"VmType" json:"VmType"`
IsTemplate interface{} IsTemplate interface{} `db:"IsTemplate" json:"IsTemplate"`
Datacenter sql.NullString Datacenter sql.NullString `db:"Datacenter" json:"Datacenter"`
Cluster sql.NullString Cluster sql.NullString `db:"Cluster" json:"Cluster"`
Folder sql.NullString Folder sql.NullString `db:"Folder" json:"Folder"`
ProvisionedDisk sql.NullFloat64 ProvisionedDisk sql.NullFloat64 `db:"ProvisionedDisk" json:"ProvisionedDisk"`
InitialVcpus sql.NullInt64 InitialVcpus sql.NullInt64 `db:"InitialVcpus" json:"InitialVcpus"`
InitialRam sql.NullInt64 InitialRam sql.NullInt64 `db:"InitialRam" json:"InitialRam"`
SrmPlaceholder interface{} SrmPlaceholder interface{} `db:"SrmPlaceholder" json:"SrmPlaceholder"`
PoweredOn interface{} PoweredOn interface{} `db:"PoweredOn" json:"PoweredOn"`
} }
func (q *Queries) CreateInventory(ctx context.Context, arg CreateInventoryParams) (Inventory, error) { func (q *Queries) CreateInventory(ctx context.Context, arg CreateInventoryParams) (Inventory, error) {
@@ -186,13 +186,13 @@ RETURNING Hid, InventoryId, ReportDate, UpdateTime, PreviousVcpus, PreviousRam,
` `
type CreateInventoryHistoryParams struct { type CreateInventoryHistoryParams struct {
InventoryId sql.NullInt64 InventoryId sql.NullInt64 `db:"InventoryId" json:"InventoryId"`
ReportDate sql.NullInt64 ReportDate sql.NullInt64 `db:"ReportDate" json:"ReportDate"`
UpdateTime sql.NullInt64 UpdateTime sql.NullInt64 `db:"UpdateTime" json:"UpdateTime"`
PreviousVcpus sql.NullInt64 PreviousVcpus sql.NullInt64 `db:"PreviousVcpus" json:"PreviousVcpus"`
PreviousRam sql.NullInt64 PreviousRam sql.NullInt64 `db:"PreviousRam" json:"PreviousRam"`
PreviousResourcePool sql.NullString PreviousResourcePool sql.NullString `db:"PreviousResourcePool" json:"PreviousResourcePool"`
PreviousProvisionedDisk sql.NullFloat64 PreviousProvisionedDisk sql.NullFloat64 `db:"PreviousProvisionedDisk" json:"PreviousProvisionedDisk"`
} }
func (q *Queries) CreateInventoryHistory(ctx context.Context, arg CreateInventoryHistoryParams) (InventoryHistory, error) { func (q *Queries) CreateInventoryHistory(ctx context.Context, arg CreateInventoryHistoryParams) (InventoryHistory, error) {
@@ -229,19 +229,19 @@ RETURNING Uid, InventoryId, UpdateTime, UpdateType, NewVcpus, NewRam, NewResourc
` `
type CreateUpdateParams struct { type CreateUpdateParams struct {
InventoryId sql.NullInt64 InventoryId sql.NullInt64 `db:"InventoryId" json:"InventoryId"`
Name sql.NullString Name sql.NullString `db:"Name" json:"Name"`
EventKey sql.NullString EventKey sql.NullString `db:"EventKey" json:"EventKey"`
EventId sql.NullString EventId sql.NullString `db:"EventId" json:"EventId"`
UpdateTime sql.NullInt64 UpdateTime sql.NullInt64 `db:"UpdateTime" json:"UpdateTime"`
UpdateType string UpdateType string `db:"UpdateType" json:"UpdateType"`
NewVcpus sql.NullInt64 NewVcpus sql.NullInt64 `db:"NewVcpus" json:"NewVcpus"`
NewRam sql.NullInt64 NewRam sql.NullInt64 `db:"NewRam" json:"NewRam"`
NewResourcePool sql.NullString NewResourcePool sql.NullString `db:"NewResourcePool" json:"NewResourcePool"`
NewProvisionedDisk sql.NullFloat64 NewProvisionedDisk sql.NullFloat64 `db:"NewProvisionedDisk" json:"NewProvisionedDisk"`
UserName sql.NullString UserName sql.NullString `db:"UserName" json:"UserName"`
PlaceholderChange sql.NullString PlaceholderChange sql.NullString `db:"PlaceholderChange" json:"PlaceholderChange"`
RawChangeString []byte RawChangeString []byte `db:"RawChangeString" json:"RawChangeString"`
} }
func (q *Queries) CreateUpdate(ctx context.Context, arg CreateUpdateParams) (Update, error) { func (q *Queries) CreateUpdate(ctx context.Context, arg CreateUpdateParams) (Update, error) {
@@ -466,8 +466,8 @@ WHERE "VmId" = ?1 AND "Datacenter" = ?2
` `
type GetInventoryVmIdParams struct { type GetInventoryVmIdParams struct {
VmId sql.NullString VmId sql.NullString `db:"vmId" json:"vmId"`
DatacenterName sql.NullString DatacenterName sql.NullString `db:"datacenterName" json:"datacenterName"`
} }
func (q *Queries) GetInventoryVmId(ctx context.Context, arg GetInventoryVmIdParams) (Inventory, error) { func (q *Queries) GetInventoryVmId(ctx context.Context, arg GetInventoryVmIdParams) (Inventory, error) {
@@ -504,8 +504,8 @@ WHERE "VmUuid" = ?1 AND "Datacenter" = ?2
` `
type GetInventoryVmUuidParams struct { type GetInventoryVmUuidParams struct {
VmUuid sql.NullString VmUuid sql.NullString `db:"vmUuid" json:"vmUuid"`
DatacenterName sql.NullString DatacenterName sql.NullString `db:"datacenterName" json:"datacenterName"`
} }
func (q *Queries) GetInventoryVmUuid(ctx context.Context, arg GetInventoryVmUuidParams) (Inventory, error) { func (q *Queries) GetInventoryVmUuid(ctx context.Context, arg GetInventoryVmUuidParams) (Inventory, error) {
@@ -634,8 +634,8 @@ WHERE "UpdateType" = ?1 AND "InventoryId" = ?2
` `
type GetVmUpdatesParams struct { type GetVmUpdatesParams struct {
UpdateType string UpdateType string `db:"updateType" json:"updateType"`
InventoryId sql.NullInt64 InventoryId sql.NullInt64 `db:"InventoryId" json:"InventoryId"`
} }
func (q *Queries) GetVmUpdates(ctx context.Context, arg GetVmUpdatesParams) ([]Update, error) { func (q *Queries) GetVmUpdates(ctx context.Context, arg GetVmUpdatesParams) ([]Update, error) {
@@ -683,8 +683,8 @@ RETURNING Iid, Name, Vcenter, VmId, EventKey, CloudId, CreationTime, DeletionTim
` `
type InventoryCleanupParams struct { type InventoryCleanupParams struct {
VmId sql.NullString VmId sql.NullString `db:"vmId" json:"vmId"`
DatacenterName sql.NullString DatacenterName sql.NullString `db:"datacenterName" json:"datacenterName"`
} }
func (q *Queries) InventoryCleanup(ctx context.Context, arg InventoryCleanupParams) error { func (q *Queries) InventoryCleanup(ctx context.Context, arg InventoryCleanupParams) error {
@@ -721,9 +721,9 @@ WHERE "VmId" = ?2 AND "Datacenter" = ?3
` `
type InventoryMarkDeletedParams struct { type InventoryMarkDeletedParams struct {
DeletionTime sql.NullInt64 DeletionTime sql.NullInt64 `db:"deletionTime" json:"deletionTime"`
VmId sql.NullString VmId sql.NullString `db:"vmId" json:"vmId"`
DatacenterName sql.NullString DatacenterName sql.NullString `db:"datacenterName" json:"datacenterName"`
} }
func (q *Queries) InventoryMarkDeleted(ctx context.Context, arg InventoryMarkDeletedParams) error { func (q *Queries) InventoryMarkDeleted(ctx context.Context, arg InventoryMarkDeletedParams) error {
@@ -738,9 +738,9 @@ WHERE "Iid" = ?3
` `
type InventoryUpdateParams struct { type InventoryUpdateParams struct {
Uuid sql.NullString Uuid sql.NullString `db:"uuid" json:"uuid"`
SrmPlaceholder interface{} SrmPlaceholder interface{} `db:"srmPlaceholder" json:"srmPlaceholder"`
Iid int64 Iid int64 `db:"iid" json:"iid"`
} }
func (q *Queries) InventoryUpdate(ctx context.Context, arg InventoryUpdateParams) error { func (q *Queries) InventoryUpdate(ctx context.Context, arg InventoryUpdateParams) error {

View File

@@ -584,6 +584,63 @@ const docTemplate = `{
} }
} }
}, },
"/api/snapshots/aggregate": {
"post": {
"description": "Forces regeneration of a daily or monthly summary table for a specified date or month.",
"produces": [
"application/json"
],
"tags": [
"snapshots"
],
"summary": "Force snapshot aggregation",
"parameters": [
{
"type": "string",
"description": "Aggregation type: daily or monthly",
"name": "type",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Daily date (YYYY-MM-DD) or monthly date (YYYY-MM)",
"name": "date",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "Aggregation complete",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "Invalid request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Server error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/snapshots/daily": { "/snapshots/daily": {
"get": { "get": {
"description": "Lists daily summary snapshot tables.", "description": "Lists daily summary snapshot tables.",

View File

@@ -573,6 +573,63 @@
} }
} }
}, },
"/api/snapshots/aggregate": {
"post": {
"description": "Forces regeneration of a daily or monthly summary table for a specified date or month.",
"produces": [
"application/json"
],
"tags": [
"snapshots"
],
"summary": "Force snapshot aggregation",
"parameters": [
{
"type": "string",
"description": "Aggregation type: daily or monthly",
"name": "type",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Daily date (YYYY-MM-DD) or monthly date (YYYY-MM)",
"name": "date",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "Aggregation complete",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "Invalid request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Server error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/snapshots/daily": { "/snapshots/daily": {
"get": { "get": {
"description": "Lists daily summary snapshot tables.", "description": "Lists daily summary snapshot tables.",

View File

@@ -530,6 +530,45 @@ paths:
summary: Download updates report summary: Download updates report
tags: tags:
- reports - reports
/api/snapshots/aggregate:
post:
description: Forces regeneration of a daily or monthly summary table for a specified
date or month.
parameters:
- description: 'Aggregation type: daily or monthly'
in: query
name: type
required: true
type: string
- description: Daily date (YYYY-MM-DD) or monthly date (YYYY-MM)
in: query
name: date
required: true
type: string
produces:
- application/json
responses:
"200":
description: Aggregation complete
schema:
additionalProperties:
type: string
type: object
"400":
description: Invalid request
schema:
additionalProperties:
type: string
type: object
"500":
description: Server error
schema:
additionalProperties:
type: string
type: object
summary: Force snapshot aggregation
tags:
- snapshots
/snapshots/daily: /snapshots/daily:
get: get:
description: Lists daily summary snapshot tables. description: Lists daily summary snapshot tables.