Files
vctp2/server/router/docs/swagger.yaml
T
nathan 7848557002
continuous-integration/drone/push Build is passing
update docs
2026-04-17 14:00:48 +10:00

1253 lines
33 KiB
YAML

basePath: /
definitions:
models.AuthLoginRequest:
properties:
password:
type: string
username:
type: string
type: object
models.AuthLoginResponse:
properties:
access_token:
type: string
expires_at:
type: integer
token_type:
type: string
type: object
models.AuthMeResponse:
properties:
audience:
type: string
expires_at:
type: integer
groups:
items:
type: string
type: array
issued_at:
type: integer
issuer:
type: string
not_before:
type: integer
roles:
items:
type: string
type: array
status:
type: string
subject:
type: string
token_id:
type: string
type: object
models.CloudEventReceived:
properties:
cloudEvent:
properties:
data:
properties:
ChainId:
type: integer
ChangeTag:
type: string
ComputeResource:
properties:
ComputeResource:
properties:
Type:
type: string
Value:
type: string
type: object
Name:
type: string
type: object
CreatedTime:
description: Modified from time.Time
type: string
Datacenter:
properties:
Datacenter:
properties:
Type:
type: string
Value:
type: string
type: object
Name:
type: string
type: object
Ds: {}
Dvs: {}
FullFormattedMessage:
type: string
Host:
properties:
Host:
properties:
Type:
type: string
Value:
type: string
type: object
Name:
type: string
type: object
Key:
type: integer
Net: {}
NewParent:
$ref: '#/definitions/models.CloudEventResourcePool'
OldParent:
$ref: '#/definitions/models.CloudEventResourcePool'
SrcTemplate:
$ref: '#/definitions/models.CloudEventVm'
Template:
type: boolean
UserName:
type: string
Vm:
properties:
Name:
type: string
Vm:
properties:
Type:
type: string
Value:
type: string
type: object
type: object
configChanges:
allOf:
- $ref: '#/definitions/models.ConfigChangesReceived'
description: Modified to separate struct
configSpec:
type: object
type: object
id:
type: string
source:
type: string
specversion:
type: string
time:
description: Modified from time.Time
type: string
type:
type: string
type: object
type: object
models.CloudEventResourcePool:
properties:
Name:
type: string
ResourcePool:
properties:
Type:
type: string
Value:
type: string
type: object
type: object
models.CloudEventVm:
properties:
Name:
type: string
Vm:
properties:
Type:
type: string
Value:
type: string
type: object
type: object
models.ConfigChangesReceived:
properties:
modified:
type: string
type: object
models.DailyCreationDiagnosticsResponse:
properties:
avg_is_present_lt_one_count:
type: integer
date:
type: string
missing_by_vcenter:
items:
$ref: '#/definitions/models.DailyCreationMissingByVcenter'
type: array
missing_creation_count:
type: integer
missing_creation_partial_count:
type: integer
missing_creation_partial_samples:
items:
$ref: '#/definitions/models.DailyCreationMissingSample'
type: array
missing_creation_pct:
type: number
samples:
items:
$ref: '#/definitions/models.DailyCreationMissingSample'
type: array
status:
type: string
table:
type: string
total_rows:
type: integer
type: object
models.DailyCreationMissingByVcenter:
properties:
missing_count:
type: integer
vcenter:
type: string
type: object
models.DailyCreationMissingSample:
properties:
avg_is_present:
type: number
name:
type: string
samples_present:
type: integer
snapshot_time:
type: integer
vcenter:
type: string
vm_id:
type: string
vm_uuid:
type: string
type: object
models.ErrorResponse:
properties:
message:
type: string
status:
type: string
type: object
models.ImportReceived:
properties:
Cluster:
type: string
CreationTime:
type: integer
Datacenter:
type: string
Folder:
type: string
InitialRam:
type: integer
InitialVcpus:
type: integer
Name:
type: string
PowerState:
type: integer
ProvisionedDisk:
type: number
ResourcePool:
type: string
Vcenter:
type: string
VmId:
type: string
type: object
models.SnapshotMigrationResponse:
properties:
error:
type: string
stats:
$ref: '#/definitions/models.SnapshotMigrationStats'
status:
type: string
type: object
models.SnapshotMigrationStats:
properties:
DailyRegistered:
type: integer
Errors:
type: integer
HourlyRegistered:
type: integer
HourlyRenamed:
type: integer
MonthlyRegistered:
type: integer
type: object
models.SnapshotRegenerateReportsResponse:
properties:
errors:
type: integer
regenerated:
type: integer
reports_dir:
type: string
skipped:
type: integer
snapshotType:
type: string
status:
type: string
total:
type: integer
type: object
models.SnapshotRepairResponse:
properties:
failed:
type: string
repaired:
type: string
status:
type: string
type: object
models.SnapshotRepairSuiteResponse:
properties:
daily_failed:
type: string
daily_repaired:
type: string
monthly_failed:
type: string
monthly_refined:
type: string
status:
type: string
type: object
models.StatusMessageResponse:
properties:
message:
type: string
status:
type: string
type: object
models.StatusResponse:
properties:
status:
type: string
type: object
models.VcenterCacheRebuildResponse:
properties:
failed:
type: integer
results:
items:
$ref: '#/definitions/models.VcenterCacheRebuildResult'
type: array
status:
type: string
succeeded:
type: integer
total:
type: integer
type: object
models.VcenterCacheRebuildResult:
properties:
duration_seconds:
type: number
error:
type: string
folder_entries:
type: integer
host_entries:
type: integer
resource_pool_entries:
type: integer
vcenter:
type: string
type: object
info:
contact: {}
description: vCTP API endpoints for inventory snapshots, reporting, and administration.
title: vCTP API
version: "1.0"
paths:
/:
get:
description: Renders the main UI page.
produces:
- text/html
responses:
"200":
description: HTML page
schema:
type: string
"500":
description: Render failed
schema:
type: string
summary: Home page
tags:
- ui
/api/auth/login:
post:
consumes:
- application/json
description: Authenticates a username/password against LDAP and returns a signed
access token.
parameters:
- description: Login credentials
in: body
name: payload
required: true
schema:
$ref: '#/definitions/models.AuthLoginRequest'
produces:
- application/json
responses:
"200":
description: Login success
schema:
$ref: '#/definitions/models.AuthLoginResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Invalid credentials
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
"503":
description: Authentication disabled
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: Login
tags:
- auth
/api/auth/me:
get:
description: |-
Returns JWT claims for the currently authenticated bearer token.
Requires Bearer authentication.
produces:
- application/json
responses:
"200":
description: Authenticated identity
schema:
$ref: '#/definitions/models.AuthMeResponse'
"401":
description: Missing or invalid authentication context
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Who am I
tags:
- auth
/api/cleanup/updates:
delete:
deprecated: true
description: |-
Deprecated: Removes update records that are no longer associated with a VM.
Requires Bearer authentication with the admin role.
produces:
- text/plain
responses:
"200":
description: Cleanup completed
schema:
type: string
"500":
description: Server error
schema:
type: string
security:
- BearerAuth: []
summary: Cleanup updates (deprecated)
tags:
- maintenance
/api/cleanup/vcenter:
delete:
deprecated: true
description: 'Deprecated: Removes all inventory entries associated with a vCenter
URL.'
parameters:
- description: vCenter URL
in: query
name: vc_url
required: true
type: string
produces:
- application/json
responses:
"200":
description: Cleanup completed
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: Cleanup vCenter inventory (deprecated)
tags:
- maintenance
/api/diagnostics/daily-creation:
get:
description: |-
Returns counts of daily summary rows missing CreationTime and sample rows for the given date.
Requires Bearer authentication with the viewer role (admin also allowed).
parameters:
- description: Daily date (YYYY-MM-DD)
in: query
name: date
required: true
type: string
produces:
- application/json
responses:
"200":
description: Diagnostics result
schema:
$ref: '#/definitions/models.DailyCreationDiagnosticsResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"404":
description: Summary not found
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Daily summary CreationTime diagnostics
tags:
- diagnostics
/api/encrypt:
post:
consumes:
- application/json
description: |-
Encrypts a plaintext value and returns the ciphertext.
Requires Bearer authentication with the admin role.
parameters:
- description: Plaintext payload
in: body
name: payload
required: true
schema:
additionalProperties:
type: string
type: object
produces:
- application/json
responses:
"200":
description: Ciphertext response
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Encrypt data
tags:
- crypto
/api/event/vm/create:
post:
consumes:
- application/json
deprecated: true
description: |-
Deprecated: Parses a VM create CloudEvent and stores the event data.
Requires Bearer authentication with the admin role.
parameters:
- description: CloudEvent payload
in: body
name: event
required: true
schema:
$ref: '#/definitions/models.CloudEventReceived'
produces:
- application/json
responses:
"200":
description: Create event processed
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Record VM create event (deprecated)
tags:
- events
/api/event/vm/delete:
post:
consumes:
- application/json
deprecated: true
description: |-
Deprecated: Parses a VM delete CloudEvent and marks the VM as deleted in inventory.
Requires Bearer authentication with the admin role.
parameters:
- description: CloudEvent payload
in: body
name: event
required: true
schema:
$ref: '#/definitions/models.CloudEventReceived'
produces:
- application/json
responses:
"200":
description: Delete event processed
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Record VM delete event (deprecated)
tags:
- events
/api/event/vm/modify:
post:
consumes:
- application/json
deprecated: true
description: |-
Deprecated: Parses a VM modify CloudEvent and creates an update record when relevant changes are detected.
Requires Bearer authentication with the admin role.
parameters:
- description: CloudEvent payload
in: body
name: event
required: true
schema:
$ref: '#/definitions/models.CloudEventReceived'
produces:
- application/json
responses:
"200":
description: Modify event processed
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"202":
description: No relevant changes
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Record VM modify event (deprecated)
tags:
- events
/api/event/vm/move:
post:
consumes:
- application/json
deprecated: true
description: |-
Deprecated: Parses a VM move CloudEvent and creates an update record.
Requires Bearer authentication with the admin role.
parameters:
- description: CloudEvent payload
in: body
name: event
required: true
schema:
$ref: '#/definitions/models.CloudEventReceived'
produces:
- application/json
responses:
"200":
description: Move event processed
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Record VM move event (deprecated)
tags:
- events
/api/import/vm:
post:
consumes:
- application/json
deprecated: true
description: |-
Deprecated: Imports existing VM inventory data in bulk.
Requires Bearer authentication with the admin role.
parameters:
- description: Bulk import payload
in: body
name: import
required: true
schema:
$ref: '#/definitions/models.ImportReceived'
produces:
- application/json
responses:
"200":
description: Import processed
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Import VMs (deprecated)
tags:
- inventory
/api/inventory/vm/delete:
delete:
deprecated: true
description: |-
Deprecated: Removes a VM inventory entry by VM ID and datacenter name.
Requires Bearer authentication with the admin role.
parameters:
- description: VM ID
in: query
name: vm_id
required: true
type: string
- description: Datacenter name
in: query
name: datacenter_name
required: true
type: string
produces:
- application/json
responses:
"200":
description: Cleanup completed
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Cleanup VM inventory entry (deprecated)
tags:
- inventory
/api/inventory/vm/update:
post:
deprecated: true
description: |-
Deprecated: Queries vCenter and updates inventory records with missing details.
Requires Bearer authentication with the admin role.
produces:
- application/json
responses:
"200":
description: Update completed
schema:
$ref: '#/definitions/models.StatusMessageResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Refresh VM details (deprecated)
tags:
- inventory
/api/report/inventory:
get:
description: |-
Generates an inventory XLSX report and returns it as a file download.
Requires Bearer authentication with the viewer role (admin also allowed).
produces:
- application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
responses:
"200":
description: Inventory XLSX report
schema:
type: file
"500":
description: Report generation failed
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Download inventory report
tags:
- reports
/api/report/snapshot:
get:
description: |-
Downloads a snapshot table as an XLSX file.
Requires Bearer authentication with the viewer role (admin also allowed).
parameters:
- description: Snapshot table name
in: query
name: table
required: true
type: string
produces:
- application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
responses:
"200":
description: Snapshot XLSX report
schema:
type: file
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Download snapshot report
tags:
- snapshots
/api/report/updates:
get:
description: |-
Generates an updates XLSX report and returns it as a file download.
Requires Bearer authentication with the viewer role (admin also allowed).
produces:
- application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
responses:
"200":
description: Updates XLSX report
schema:
type: file
"500":
description: Report generation failed
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Download updates report
tags:
- reports
/api/snapshots/aggregate:
post:
description: |-
Forces regeneration of a daily or monthly summary table for a specified date or month.
Requires Bearer authentication with the admin role.
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
- description: 'Monthly aggregation granularity: hourly or daily'
in: query
name: granularity
type: string
produces:
- application/json
responses:
"200":
description: Aggregation complete
schema:
$ref: '#/definitions/models.StatusResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Force snapshot aggregation
tags:
- snapshots
/api/snapshots/hourly/force:
post:
consumes:
- application/json
description: |-
Manually trigger an hourly snapshot for all configured vCenters. Requires confirmation text to avoid accidental execution.
Requires Bearer authentication with the admin role.
parameters:
- description: Confirmation text; must be 'FORCE'
in: query
name: confirm
required: true
type: string
produces:
- application/json
responses:
"200":
description: Snapshot started
schema:
$ref: '#/definitions/models.StatusResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Trigger hourly snapshot (manual)
tags:
- snapshots
/api/snapshots/migrate:
post:
description: |-
Rebuilds the snapshot registry from existing tables and renames hourly tables to epoch-based names.
Requires Bearer authentication with the admin role.
produces:
- application/json
responses:
"200":
description: Migration results
schema:
$ref: '#/definitions/models.SnapshotMigrationResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.SnapshotMigrationResponse'
security:
- BearerAuth: []
summary: Migrate snapshot registry
tags:
- snapshots
/api/snapshots/regenerate-hourly-reports:
post:
description: |-
Regenerates XLSX reports for hourly snapshots when the report files are missing or empty.
Requires Bearer authentication with the admin role.
produces:
- application/json
responses:
"200":
description: Regeneration summary
schema:
$ref: '#/definitions/models.SnapshotRegenerateReportsResponse'
"500":
description: Server error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: Regenerate hourly snapshot reports
tags:
- snapshots
/api/snapshots/repair:
post:
description: |-
Backfills SnapshotTime and lifecycle info for existing daily summary tables and reruns monthly lifecycle refinement using hourly data.
Requires Bearer authentication with the admin role.
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.SnapshotRepairResponse'
security:
- BearerAuth: []
summary: Repair daily summaries
tags:
- snapshots
/api/snapshots/repair/all:
post:
description: |-
Rebuilds snapshot registry, backfills per-vCenter totals, repairs daily summaries (SnapshotTime/lifecycle), and refines monthly lifecycle.
Requires Bearer authentication with the admin role.
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.SnapshotRepairSuiteResponse'
security:
- BearerAuth: []
summary: Run full snapshot repair suite
tags:
- snapshots
/api/vcenters/cache/rebuild:
post:
description: |-
Rebuilds cached folder/resource-pool/host(cluster+datacenter) references from vCenter and rewrites the database cache tables.
Requires Bearer authentication with the admin role.
parameters:
- description: Optional single vCenter URL to rebuild; defaults to all configured
vCenters
in: query
name: vcenter
type: string
produces:
- application/json
responses:
"200":
description: Cache rebuild summary
schema:
$ref: '#/definitions/models.VcenterCacheRebuildResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/models.ErrorResponse'
"405":
description: Method not allowed
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: All rebuild attempts failed
schema:
$ref: '#/definitions/models.VcenterCacheRebuildResponse'
security:
- BearerAuth: []
summary: Rebuild vCenter object cache
tags:
- vcenters
/metrics:
get:
description: Exposes Prometheus metrics for vctp.
produces:
- text/plain
responses:
"200":
description: Prometheus metrics
summary: Prometheus metrics
tags:
- metrics
/snapshots/daily:
get:
description: Lists daily summary snapshot tables.
produces:
- text/html
responses:
"200":
description: HTML page
schema:
type: string
"500":
description: Server error
schema:
type: string
summary: List daily snapshots
tags:
- snapshots
/snapshots/hourly:
get:
description: Lists hourly inventory snapshot tables.
produces:
- text/html
responses:
"200":
description: HTML page
schema:
type: string
"500":
description: Server error
schema:
type: string
summary: List hourly snapshots
tags:
- snapshots
/snapshots/monthly:
get:
description: Lists monthly summary snapshot tables.
produces:
- text/html
responses:
"200":
description: HTML page
schema:
type: string
"500":
description: Server error
schema:
type: string
summary: List monthly snapshots
tags:
- snapshots
/vcenters:
get:
description: Lists all vCenters with recorded snapshot totals, linking to the
fast daily aggregated totals page.
produces:
- text/html
responses:
"200":
description: HTML page
schema:
type: string
summary: List vCenters
tags:
- vcenters
/vcenters/totals:
get:
description: Redirect-style handler for compatibility; use /vcenters/totals/daily
or /vcenters/totals/hourly.
parameters:
- description: vCenter URL
in: query
name: vcenter
required: true
type: string
- description: hourly|daily|monthly
in: query
name: type
type: string
- description: Limit results
in: query
name: limit
type: integer
produces:
- text/html
responses:
"200":
description: HTML page
schema:
type: string
"400":
description: Missing vcenter
schema:
type: string
summary: vCenter totals
tags:
- vcenters
/vcenters/totals/daily:
get:
description: Shows daily aggregated VM count/vCPU/RAM totals for a vCenter (cache-backed
for fast loading).
parameters:
- description: vCenter URL
in: query
name: vcenter
required: true
type: string
- description: Limit results (default 400)
in: query
name: limit
type: integer
produces:
- text/html
responses:
"200":
description: HTML page
schema:
type: string
"400":
description: Missing vcenter
schema:
type: string
summary: vCenter daily totals
tags:
- vcenters
/vcenters/totals/hourly:
get:
description: Shows detailed hourly VM count/vCPU/RAM totals for the latest 45
days.
parameters:
- description: vCenter URL
in: query
name: vcenter
required: true
type: string
produces:
- text/html
responses:
"200":
description: HTML page
schema:
type: string
"400":
description: Missing vcenter
schema:
type: string
summary: vCenter hourly totals (45 days)
tags:
- vcenters
/vm/trace:
get:
description: Shows VM resource history with an hourly detail view and a daily
aggregated view, with chart and table output.
parameters:
- description: VM ID
in: query
name: vm_id
type: string
- description: VM UUID
in: query
name: vm_uuid
type: string
- description: VM name
in: query
name: name
type: string
- description: 'hourly|daily (default: hourly)'
in: query
name: view
type: string
produces:
- text/html
responses:
"200":
description: HTML page
schema:
type: string
"400":
description: Missing identifier
schema:
type: string
summary: Trace VM history
tags:
- vm
schemes:
- http
- https
securityDefinitions:
BearerAuth:
in: header
name: Authorization
type: apiKey
swagger: "2.0"