UNPKG

@vigilbase/cli

Version:

Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.

249 lines (248 loc) • 10.5 kB
// GENERATED from packages/api-contract/src/one/v1/customer-records.ts by scripts/vendor-api-contract.mjs — do not edit import { z } from 'zod'; import { defineOperation } from '../../core/operation.js'; import { CustomerParams, Id, ListQuery, ONE_READ_AUTH, ONE_WRITE_AUTH, page, READ_ERRORS, Timestamp, WRITE_ERRORS, } from './shared.js'; /** * A customer's own records: contacts, login organisation, service records, * endpoint inventory and monitoring incidents. Each read is what the legacy * customer-facing route returns, curated: no raw provider payloads, internal * ids or billing links. */ /** One person on the customer's contact list. */ export const CustomerContact = z .object({ name: z.string().nullable(), email: z.string().nullable(), phone: z.string().nullable(), role: z.string().nullable(), isTechnicalContact: z.boolean(), isBillingContact: z.boolean(), }) .meta({ id: 'CustomerContact' }); /** Whether the customer has its login organisation in Vigilbase Identity. */ export const CustomerOrganization = z .object({ hasOrganization: z.boolean(), organizationId: z.string().nullable().meta({ description: 'The Identity organisation the customer’s people sign in to.' }), }) .meta({ id: 'CustomerOrganization' }); /** One service Vigilbase runs for the customer. */ export const CustomerService = z .object({ id: Id, tool: z.string().meta({ description: 'Integration tool, e.g. cloudflare, ninja-one.' }), status: z.enum(['active', 'inactive', 'pending', 'error']), serviceType: z.string().nullable(), billingTier: z.string(), linkedAccountId: z.string().meta({ description: 'The customer’s account at the provider.' }), domain: z.string().nullable(), bandwidthLimitTb: z.number().nullable(), monthlyAmount: z.number().nullable().meta({ description: 'Null unless the caller may read billing amounts.' }), currentPeriodStart: Timestamp.nullable(), currentPeriodEnd: Timestamp.nullable(), createdAt: Timestamp.nullable(), updatedAt: Timestamp.nullable(), }) .meta({ id: 'CustomerService' }); /** One device in the customer's endpoint inventory. */ export const CustomerEndpoint = z .object({ id: Id, displayName: z.string(), systemName: z.string(), dnsName: z.string().nullable(), deviceType: z.string().nullable(), nodeClass: z.string().nullable().meta({ description: 'Device class, e.g. WINDOWS_WORKSTATION, MAC.' }), integration: z.string().nullable().meta({ description: 'The integration that reports it, e.g. ninja-one.' }), offline: z.boolean(), approvalStatus: z.string().nullable(), maintenanceStatus: z.string().nullable(), ipAddresses: z.array(z.string()), publicIp: z.string().nullable(), locationName: z.string().nullable(), lastLoggedOnUser: z.string().nullable(), lastContact: Timestamp.nullable(), lastUpdate: Timestamp.nullable(), createdAt: Timestamp.nullable(), updatedAt: Timestamp.nullable(), }) .meta({ id: 'CustomerEndpoint' }); /** Who said "I've got this" on an incident. */ export const IncidentAcknowledgement = z .object({ byName: z.string().nullable(), byEmail: z.string().nullable(), at: Timestamp, note: z.string().nullable(), }) .meta({ id: 'IncidentAcknowledgement' }); export const CustomerIncidentEvent = z .object({ id: Id, transition: z.string().meta({ description: 'Triggered, Re-Triggered, Warn, No Data, Recovered, …' }), title: z.string().nullable(), region: z.string().nullable(), occurredAt: Timestamp, }) .meta({ id: 'CustomerIncidentEvent' }); /** A run of one monitor's alerts for the customer, from the first alert to its recovery. */ export const CustomerIncident = z .object({ key: z.string().meta({ description: 'Stable incident key; use it to acknowledge.' }), monitorName: z.string().nullable(), category: z.string().nullable(), severity: z.enum(['warning', 'critical']), status: z.enum(['open', 'resolved']), region: z.string().nullable(), targetId: z.string().nullable(), startedAt: Timestamp, resolvedAt: Timestamp.nullable(), startedOutsideWindow: z.boolean().meta({ description: 'The first alert is older than the window; startedAt is the first one seen.' }), lastTransition: z.string(), eventCount: z.number().int(), hadNoData: z.boolean(), events: z.array(CustomerIncidentEvent), acknowledgement: IncidentAcknowledgement.nullable(), }) .meta({ id: 'CustomerIncident' }); export const CustomerIncidentsQuery = ListQuery.extend({ windowDays: z.coerce.number().int().min(1).max(90).default(30).meta({ description: 'Days back to look, 1–90.' }), }); export const CustomerIncidentParams = z.object({ customerId: Id, incidentId: Id }); export const AcknowledgeIncidentBody = z .strictObject({ note: z.string().trim().max(500).optional() }) .optional(); export const IncidentAcknowledgementResult = z .object({ incidentKey: Id, acknowledgement: IncidentAcknowledgement, created: z.boolean().meta({ description: 'False when the incident was already acknowledged; that acknowledgement is returned.' }), }) .meta({ id: 'IncidentAcknowledgementResult' }); export const listCustomerContacts = defineOperation({ id: 'one.customerContacts.list', product: 'one', version: 'v1', method: 'GET', path: '/customers/{customerId}/contacts', summary: 'List a customer’s contacts', description: 'The people on the customer’s contact list, with their technical and billing roles, in list order.', tags: ['customers'], stability: 'beta', audience: 'customer', auth: ONE_READ_AUTH, permissions: ['read:customers'], pagination: 'cursor', request: { params: CustomerParams, query: ListQuery }, responses: { 200: page(CustomerContact) }, errors: READ_ERRORS, legacy: [{ host: 'one', path: '/api/customers/{id}/contacts' }], expose: { mcp: 'code-mode', cli: 'customers contacts', llms: true }, }); export const getCustomerOrganization = defineOperation({ id: 'one.customerOrganization.get', product: 'one', version: 'v1', method: 'GET', path: '/customers/{customerId}/organization', summary: 'Get a customer’s login organisation', description: 'Whether the customer has its Vigilbase Identity organisation, and its id.', tags: ['customers'], stability: 'beta', audience: 'customer', auth: ONE_READ_AUTH, permissions: ['read:customers'], request: { params: CustomerParams }, responses: { 200: CustomerOrganization }, errors: READ_ERRORS, legacy: [{ host: 'one', path: '/api/customers/{id}/organization' }], expose: { mcp: 'code-mode', cli: 'customers organization', llms: true }, }); export const listCustomerServices = defineOperation({ id: 'one.customerServices.list', product: 'one', version: 'v1', method: 'GET', path: '/customers/{customerId}/services', summary: 'List a customer’s services', description: 'The services Vigilbase runs for the customer, newest first. Billing amounts need read:billing.', tags: ['customers'], stability: 'beta', audience: 'customer', auth: ONE_READ_AUTH, permissions: ['read:services'], pagination: 'cursor', request: { params: CustomerParams, query: ListQuery }, responses: { 200: page(CustomerService) }, errors: READ_ERRORS, legacy: [{ host: 'one', path: '/api/customers/{id}/service-records' }], expose: { mcp: 'code-mode', cli: 'customers services', llms: true }, }); export const listCustomerEndpoints = defineOperation({ id: 'one.customerEndpoints.list', product: 'one', version: 'v1', method: 'GET', path: '/customers/{customerId}/endpoints', summary: 'List a customer’s endpoints', description: 'The customer’s devices as its endpoint management reports them, by display name.', tags: ['customers'], stability: 'beta', audience: 'customer', auth: ONE_READ_AUTH, permissions: ['read:services'], pagination: 'cursor', request: { params: CustomerParams, query: ListQuery }, responses: { 200: page(CustomerEndpoint) }, errors: READ_ERRORS, legacy: [{ host: 'one', path: '/api/customers/{id}/endpoints' }], expose: { mcp: 'code-mode', cli: 'customers endpoints', llms: true }, }); export const listCustomerIncidents = defineOperation({ id: 'one.customerIncidents.list', product: 'one', version: 'v1', method: 'GET', path: '/customers/{customerId}/incidents', summary: 'List a customer’s monitoring incidents', description: 'Monitoring incidents over the last `windowDays` (default 30), newest first, with their acknowledgements. Built from at most the 500 newest alert events in the window.', tags: ['customers', 'monitoring'], stability: 'beta', audience: 'customer', auth: ONE_READ_AUTH, permissions: ['read:customers'], pagination: 'cursor', request: { params: CustomerParams, query: CustomerIncidentsQuery }, responses: { 200: page(CustomerIncident) }, errors: READ_ERRORS, legacy: [{ host: 'one', path: '/api/customers/{id}/incidents' }], expose: { mcp: 'code-mode', llms: true }, }); export const acknowledgeCustomerIncident = defineOperation({ id: 'one.customerIncidents.acknowledge', product: 'one', version: 'v1', method: 'POST', path: '/customers/{customerId}/incidents/{incidentId}/acknowledge', summary: 'Acknowledge a monitoring incident', description: '"I\'ve got this" on an incident, recorded for everyone. `incidentId` is the incident key, or any of its event ids. The first acknowledgement wins; a repeat returns it with `created: false`.', tags: ['customers', 'monitoring'], stability: 'beta', audience: 'customer', auth: ONE_WRITE_AUTH, permissions: ['read:customers'], idempotency: 'optional', request: { params: CustomerIncidentParams, body: AcknowledgeIncidentBody }, responses: { 200: IncidentAcknowledgementResult }, errors: WRITE_ERRORS, legacy: [{ host: 'one', path: '/api/customers/{id}/incidents/{incidentId}/acknowledge' }], expose: { mcp: 'code-mode', llms: true }, }); export const customerRecordOperations = [ listCustomerContacts, getCustomerOrganization, listCustomerServices, listCustomerEndpoints, listCustomerIncidents, acknowledgeCustomerIncident, ];