Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18,426 changes: 18,425 additions & 1 deletion docs/openapi/monitoring-api.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/commands/incidents/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class IncidentsResolve extends Command {
async run() {
const {args, flags} = await this.parse(IncidentsResolve)
const client = buildClient(flags)
const body = flags.message ? {message: flags.message} : undefined
const body = flags.message ? {body: flags.message} : undefined
const resp = await checkedFetch(client.POST('/api/v1/incidents/{id}/resolve', {params: {path: {id: args.id}}, body}))
this.log(`Incident '${resp.data?.incident?.title}' resolved.`)
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/notification-policies/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class NotificationPoliciesTest extends Command {
async run() {
const {args, flags} = await this.parse(NotificationPoliciesTest)
const client = buildClient(flags)
await checkedFetch(client.POST('/api/v1/notification-policies/{id}/test', {params: {path: {id: args.id}}, body: {}}))
await checkedFetch(client.POST('/api/v1/notification-policies/{id}/test', {params: {path: {id: args.id}}, body: {severity: null, monitorId: null, regions: null, eventType: null, monitorType: null, serviceId: null, componentName: null, resourceGroupIds: null}}))
this.log('Test dispatch sent.')
}
}
36 changes: 36 additions & 0 deletions src/commands/status-pages/components/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {Command, Args, Flags} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {apiPost} from '../../../lib/api-client.js'

export default class StatusPagesComponentsCreate extends Command {
static description = 'Add a component to a status page'
static examples = ['<%= config.bin %> status-pages components create <page-id> --name "API" --type STATIC']
static args = {id: Args.string({description: 'Status page ID', required: true})}
static flags = {
...globalFlags,
name: Flags.string({description: 'Component name', required: true}),
type: Flags.string({description: 'Component type', required: true, options: ['STATIC', 'MONITOR', 'GROUP']}),
'monitor-id': Flags.string({description: 'Monitor ID (required when type=MONITOR)'}),
'resource-group-id': Flags.string({description: 'Resource group ID (required when type=GROUP)'}),
'group-id': Flags.string({description: 'Component group ID for visual grouping'}),
description: Flags.string({description: 'Component description'}),
'display-order': Flags.integer({description: 'Position in the component list'}),
'exclude-from-overall': Flags.boolean({description: 'Exclude from overall status calculation'}),
'show-uptime': Flags.boolean({description: 'Whether to show the uptime bar', allowNo: true}),
}

async run() {
const {args, flags} = await this.parse(StatusPagesComponentsCreate)
const client = buildClient(flags)
const body: Record<string, unknown> = {name: flags.name, type: flags.type}
if (flags['monitor-id']) body.monitorId = flags['monitor-id']
if (flags['resource-group-id']) body.resourceGroupId = flags['resource-group-id']
if (flags['group-id']) body.groupId = flags['group-id']
if (flags.description) body.description = flags.description
if (flags['display-order'] !== undefined) body.displayOrder = flags['display-order']
if (flags['exclude-from-overall'] !== undefined) body.excludeFromOverall = flags['exclude-from-overall']
if (flags['show-uptime'] !== undefined) body.showUptime = flags['show-uptime']
const resp = await apiPost<{data?: unknown}>(client, `/api/v1/status-pages/${args.id}/components`, body)
display(this, resp.data ?? resp, flags.output)
}
}
20 changes: 20 additions & 0 deletions src/commands/status-pages/components/delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Command, Args} from '@oclif/core'
import {globalFlags, buildClient} from '../../../lib/base-command.js'
import {apiDelete} from '../../../lib/api-client.js'

export default class StatusPagesComponentsDelete extends Command {
static description = 'Remove a component from a status page'
static examples = ['<%= config.bin %> status-pages components delete <page-id> <component-id>']
static args = {
id: Args.string({description: 'Status page ID', required: true}),
'component-id': Args.string({description: 'Component ID', required: true}),
}
static flags = {...globalFlags}

async run() {
const {args, flags} = await this.parse(StatusPagesComponentsDelete)
const client = buildClient(flags)
await apiDelete(client, `/api/v1/status-pages/${args.id}/components/${args['component-id']}`)
this.log(`Component '${args['component-id']}' deleted.`)
}
}
23 changes: 23 additions & 0 deletions src/commands/status-pages/components/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {Command, Args} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {fetchPaginated} from '../../../lib/typed-api.js'

export default class StatusPagesComponentsList extends Command {
static description = 'List components on a status page'
static examples = ['<%= config.bin %> status-pages components list <page-id>']
static args = {id: Args.string({description: 'Status page ID', required: true})}
static flags = {...globalFlags}

async run() {
const {args, flags} = await this.parse(StatusPagesComponentsList)
const client = buildClient(flags)
const items = await fetchPaginated(client, `/api/v1/status-pages/${args.id}/components`)
display(this, items, flags.output, [
{header: 'ID', get: (r: any) => r.id ?? ''},

Check warning on line 16 in src/commands/status-pages/components/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
{header: 'NAME', get: (r: any) => r.name ?? ''},

Check warning on line 17 in src/commands/status-pages/components/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
{header: 'TYPE', get: (r: any) => r.type ?? ''},

Check warning on line 18 in src/commands/status-pages/components/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
{header: 'STATUS', get: (r: any) => r.currentStatus ?? ''},

Check warning on line 19 in src/commands/status-pages/components/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
{header: 'GROUP', get: (r: any) => r.groupId ?? ''},

Check warning on line 20 in src/commands/status-pages/components/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
])
}
}
37 changes: 37 additions & 0 deletions src/commands/status-pages/components/update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {Command, Args, Flags} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {apiPut} from '../../../lib/api-client.js'

export default class StatusPagesComponentsUpdate extends Command {
static description = 'Update a status page component'
static examples = ['<%= config.bin %> status-pages components update <page-id> <component-id> --name "API v2"']
static args = {
id: Args.string({description: 'Status page ID', required: true}),
'component-id': Args.string({description: 'Component ID', required: true}),
}
static flags = {
...globalFlags,
name: Flags.string({description: 'Component name'}),
description: Flags.string({description: 'Component description'}),
'group-id': Flags.string({description: 'Move to a different group'}),
'remove-from-group': Flags.boolean({description: 'Remove the component from its group'}),
'display-order': Flags.integer({description: 'Position in the component list'}),
'exclude-from-overall': Flags.boolean({description: 'Exclude from overall status calculation', allowNo: true}),
'show-uptime': Flags.boolean({description: 'Whether to show the uptime bar', allowNo: true}),
}

async run() {
const {args, flags} = await this.parse(StatusPagesComponentsUpdate)
const client = buildClient(flags)
const body: Record<string, unknown> = {}
if (flags.name) body.name = flags.name
if (flags.description !== undefined) body.description = flags.description
if (flags['group-id'] !== undefined) body.groupId = flags['group-id']
if (flags['remove-from-group']) body.removeFromGroup = true
if (flags['display-order'] !== undefined) body.displayOrder = flags['display-order']
if (flags['exclude-from-overall'] !== undefined) body.excludeFromOverall = flags['exclude-from-overall']
if (flags['show-uptime'] !== undefined) body.showUptime = flags['show-uptime']
const resp = await apiPut<{data?: unknown}>(client, `/api/v1/status-pages/${args.id}/components/${args['component-id']}`, body)
display(this, resp.data ?? resp, flags.output)
}
}
4 changes: 4 additions & 0 deletions src/commands/status-pages/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {createCreateCommand} from '../../lib/crud-commands.js'
import {STATUS_PAGES} from '../../lib/resources.js'

export default createCreateCommand(STATUS_PAGES)
4 changes: 4 additions & 0 deletions src/commands/status-pages/delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {createDeleteCommand} from '../../lib/crud-commands.js'
import {STATUS_PAGES} from '../../lib/resources.js'

export default createDeleteCommand(STATUS_PAGES)
20 changes: 20 additions & 0 deletions src/commands/status-pages/domains/add.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Command, Args, Flags} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {apiPost} from '../../../lib/api-client.js'

export default class StatusPagesDomainsAdd extends Command {
static description = 'Add a custom domain to a status page'
static examples = ['<%= config.bin %> status-pages domains add <page-id> --hostname status.example.com']
static args = {id: Args.string({description: 'Status page ID', required: true})}
static flags = {
...globalFlags,
hostname: Flags.string({description: 'Custom domain hostname', required: true}),
}

async run() {
const {args, flags} = await this.parse(StatusPagesDomainsAdd)
const client = buildClient(flags)
const resp = await apiPost<{data?: unknown}>(client, `/api/v1/status-pages/${args.id}/domains`, {hostname: flags.hostname})
display(this, resp.data ?? resp, flags.output)
}
}
22 changes: 22 additions & 0 deletions src/commands/status-pages/domains/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Command, Args} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {fetchPaginated} from '../../../lib/typed-api.js'

export default class StatusPagesDomainsList extends Command {
static description = 'List custom domains on a status page'
static examples = ['<%= config.bin %> status-pages domains list <page-id>']
static args = {id: Args.string({description: 'Status page ID', required: true})}
static flags = {...globalFlags}

async run() {
const {args, flags} = await this.parse(StatusPagesDomainsList)
const client = buildClient(flags)
const items = await fetchPaginated(client, `/api/v1/status-pages/${args.id}/domains`)
display(this, items, flags.output, [
{header: 'ID', get: (r: any) => r.id ?? ''},

Check warning on line 16 in src/commands/status-pages/domains/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
{header: 'HOSTNAME', get: (r: any) => r.hostname ?? ''},

Check warning on line 17 in src/commands/status-pages/domains/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
{header: 'VERIFIED', get: (r: any) => String(r.verified ?? '')},

Check warning on line 18 in src/commands/status-pages/domains/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
{header: 'STATUS', get: (r: any) => r.verificationStatus ?? ''},

Check warning on line 19 in src/commands/status-pages/domains/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
])
}
}
20 changes: 20 additions & 0 deletions src/commands/status-pages/domains/remove.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Command, Args} from '@oclif/core'
import {globalFlags, buildClient} from '../../../lib/base-command.js'
import {apiDelete} from '../../../lib/api-client.js'

export default class StatusPagesDomainsRemove extends Command {
static description = 'Remove a custom domain from a status page'
static examples = ['<%= config.bin %> status-pages domains remove <page-id> <domain-id>']
static args = {
id: Args.string({description: 'Status page ID', required: true}),
'domain-id': Args.string({description: 'Domain ID', required: true}),
}
static flags = {...globalFlags}

async run() {
const {args, flags} = await this.parse(StatusPagesDomainsRemove)
const client = buildClient(flags)
await apiDelete(client, `/api/v1/status-pages/${args.id}/domains/${args['domain-id']}`)
this.log(`Domain '${args['domain-id']}' removed.`)
}
}
20 changes: 20 additions & 0 deletions src/commands/status-pages/domains/verify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Command, Args} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {apiPost} from '../../../lib/api-client.js'

export default class StatusPagesDomainsVerify extends Command {
static description = 'Verify a custom domain on a status page'
static examples = ['<%= config.bin %> status-pages domains verify <page-id> <domain-id>']
static args = {
id: Args.string({description: 'Status page ID', required: true}),
'domain-id': Args.string({description: 'Domain ID', required: true}),
}
static flags = {...globalFlags}

async run() {
const {args, flags} = await this.parse(StatusPagesDomainsVerify)
const client = buildClient(flags)
const resp = await apiPost<{data?: unknown}>(client, `/api/v1/status-pages/${args.id}/domains/${args['domain-id']}/verify`, {})
display(this, resp.data ?? resp, flags.output)
}
}
4 changes: 4 additions & 0 deletions src/commands/status-pages/get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {createGetCommand} from '../../lib/crud-commands.js'
import {STATUS_PAGES} from '../../lib/resources.js'

export default createGetCommand(STATUS_PAGES)
27 changes: 27 additions & 0 deletions src/commands/status-pages/groups/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Command, Args, Flags} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {apiPost} from '../../../lib/api-client.js'

export default class StatusPagesGroupsCreate extends Command {
static description = 'Create a component group on a status page'
static examples = ['<%= config.bin %> status-pages groups create <page-id> --name "Infrastructure"']
static args = {id: Args.string({description: 'Status page ID', required: true})}
static flags = {
...globalFlags,
name: Flags.string({description: 'Group name', required: true}),
description: Flags.string({description: 'Optional group description'}),
collapsed: Flags.boolean({description: 'Whether the group is collapsed by default', allowNo: true}),
'display-order': Flags.integer({description: 'Position in the group list'}),
}

async run() {
const {args, flags} = await this.parse(StatusPagesGroupsCreate)
const client = buildClient(flags)
const body: Record<string, unknown> = {name: flags.name}
if (flags.description) body.description = flags.description
if (flags.collapsed !== undefined) body.collapsed = flags.collapsed
if (flags['display-order'] !== undefined) body.displayOrder = flags['display-order']
const resp = await apiPost<{data?: unknown}>(client, `/api/v1/status-pages/${args.id}/groups`, body)
display(this, resp.data ?? resp, flags.output)
}
}
20 changes: 20 additions & 0 deletions src/commands/status-pages/groups/delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Command, Args} from '@oclif/core'
import {globalFlags, buildClient} from '../../../lib/base-command.js'
import {apiDelete} from '../../../lib/api-client.js'

export default class StatusPagesGroupsDelete extends Command {
static description = 'Delete a component group from a status page'
static examples = ['<%= config.bin %> status-pages groups delete <page-id> <group-id>']
static args = {
id: Args.string({description: 'Status page ID', required: true}),
'group-id': Args.string({description: 'Group ID', required: true}),
}
static flags = {...globalFlags}

async run() {
const {args, flags} = await this.parse(StatusPagesGroupsDelete)
const client = buildClient(flags)
await apiDelete(client, `/api/v1/status-pages/${args.id}/groups/${args['group-id']}`)
this.log(`Group '${args['group-id']}' deleted.`)
}
}
21 changes: 21 additions & 0 deletions src/commands/status-pages/groups/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Command, Args} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {fetchPaginated} from '../../../lib/typed-api.js'

export default class StatusPagesGroupsList extends Command {
static description = 'List component groups on a status page'
static examples = ['<%= config.bin %> status-pages groups list <page-id>']
static args = {id: Args.string({description: 'Status page ID', required: true})}
static flags = {...globalFlags}

async run() {
const {args, flags} = await this.parse(StatusPagesGroupsList)
const client = buildClient(flags)
const items = await fetchPaginated(client, `/api/v1/status-pages/${args.id}/groups`)
display(this, items, flags.output, [
{header: 'ID', get: (r: any) => r.id ?? ''},

Check warning on line 16 in src/commands/status-pages/groups/list.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
{header: 'NAME', get: (r: any) => r.name ?? ''},
{header: 'ORDER', get: (r: any) => String(r.displayOrder ?? '')},
])
}
}
31 changes: 31 additions & 0 deletions src/commands/status-pages/groups/update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {Command, Args, Flags} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {apiPut} from '../../../lib/api-client.js'

export default class StatusPagesGroupsUpdate extends Command {
static description = 'Update a component group on a status page'
static examples = ['<%= config.bin %> status-pages groups update <page-id> <group-id> --name "Core"']
static args = {
id: Args.string({description: 'Status page ID', required: true}),
'group-id': Args.string({description: 'Group ID', required: true}),
}
static flags = {
...globalFlags,
name: Flags.string({description: 'Group name'}),
description: Flags.string({description: 'Group description'}),
collapsed: Flags.boolean({description: 'Whether the group is collapsed', allowNo: true}),
'display-order': Flags.integer({description: 'Position in the group list'}),
}

async run() {
const {args, flags} = await this.parse(StatusPagesGroupsUpdate)
const client = buildClient(flags)
const body: Record<string, unknown> = {}
if (flags.name) body.name = flags.name
if (flags.description !== undefined) body.description = flags.description
if (flags.collapsed !== undefined) body.collapsed = flags.collapsed
if (flags['display-order'] !== undefined) body.displayOrder = flags['display-order']
const resp = await apiPut<{data?: unknown}>(client, `/api/v1/status-pages/${args.id}/groups/${args['group-id']}`, body)
display(this, resp.data ?? resp, flags.output)
}
}
27 changes: 27 additions & 0 deletions src/commands/status-pages/incidents/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Command, Args, Flags} from '@oclif/core'
import {globalFlags, buildClient, display} from '../../../lib/base-command.js'
import {apiPost} from '../../../lib/api-client.js'

export default class StatusPagesIncidentsCreate extends Command {
static description = 'Create an incident on a status page'
static examples = ['<%= config.bin %> status-pages incidents create <page-id> --title "Outage" --impact MAJOR']
static args = {id: Args.string({description: 'Status page ID', required: true})}
static flags = {
...globalFlags,
title: Flags.string({description: 'Incident title', required: true}),
impact: Flags.string({description: 'Incident impact', required: true, options: ['NONE', 'MINOR', 'MAJOR', 'CRITICAL']}),
body: Flags.string({description: 'Initial update body in markdown', required: true}),
status: Flags.string({description: 'Incident status', options: ['INVESTIGATING', 'IDENTIFIED', 'MONITORING', 'RESOLVED']}),
scheduled: Flags.boolean({description: 'Whether this is a scheduled maintenance'}),
}

async run() {
const {args, flags} = await this.parse(StatusPagesIncidentsCreate)
const client = buildClient(flags)
const body: Record<string, unknown> = {title: flags.title, impact: flags.impact, body: flags.body}
if (flags.status) body.status = flags.status
if (flags.scheduled) body.scheduled = flags.scheduled
const resp = await apiPost<{data?: unknown}>(client, `/api/v1/status-pages/${args.id}/incidents`, body)
display(this, resp.data ?? resp, flags.output)
}
}
20 changes: 20 additions & 0 deletions src/commands/status-pages/incidents/delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Command, Args} from '@oclif/core'
import {globalFlags, buildClient} from '../../../lib/base-command.js'
import {apiDelete} from '../../../lib/api-client.js'

export default class StatusPagesIncidentsDelete extends Command {
static description = 'Delete a status page incident'
static examples = ['<%= config.bin %> status-pages incidents delete <page-id> <incident-id>']
static args = {
id: Args.string({description: 'Status page ID', required: true}),
'incident-id': Args.string({description: 'Incident ID', required: true}),
}
static flags = {...globalFlags}

async run() {
const {args, flags} = await this.parse(StatusPagesIncidentsDelete)
const client = buildClient(flags)
await apiDelete(client, `/api/v1/status-pages/${args.id}/incidents/${args['incident-id']}`)
this.log(`Incident '${args['incident-id']}' deleted.`)
}
}
Loading
Loading