@heroku-cli/heroku-connect-plugin 0.11.5 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -13
- package/commands/connect/db/set.js +69 -0
- package/commands/connect/diagnose.js +36 -31
- package/commands/connect/export.js +29 -24
- package/commands/connect/import.js +32 -25
- package/commands/connect/info.js +27 -23
- package/commands/connect/mapping/delete.js +35 -0
- package/commands/connect/mapping/diagnose.js +35 -0
- package/commands/connect/mapping/reload.js +33 -0
- package/commands/connect/mapping/state.js +28 -0
- package/commands/connect/mapping/write-errors.js +28 -0
- package/commands/connect/notifications/acknowledge.js +34 -0
- package/commands/connect/notifications/index.js +57 -0
- package/commands/connect/pause.js +25 -20
- package/commands/connect/recover.js +27 -21
- package/commands/connect/resume.js +25 -20
- package/commands/connect/sf/auth.js +75 -0
- package/commands/connect/state.js +32 -29
- package/commands/connect/write-errors.js +24 -23
- package/commands/connect-events/db/set.js +72 -0
- package/commands/connect-events/info.js +27 -24
- package/commands/connect-events/pause.js +24 -20
- package/commands/connect-events/recover.js +26 -21
- package/commands/connect-events/resume.js +24 -20
- package/commands/connect-events/{sf-auth.js → sf/auth.js} +33 -27
- package/commands/connect-events/state.js +24 -18
- package/commands/connect-events/stream/create.js +39 -0
- package/commands/connect-events/stream/delete.js +40 -0
- package/commands/connect-events/stream/state.js +33 -0
- package/lib/clients/connect.js +5 -4
- package/lib/clients/discovery.js +3 -2
- package/lib/connect/api.js +85 -107
- package/package.json +44 -11
- package/commands/connect/db-set.js +0 -69
- package/commands/connect/mapping-delete.js +0 -33
- package/commands/connect/mapping-diagnose.js +0 -33
- package/commands/connect/mapping-reload.js +0 -31
- package/commands/connect/mapping-state.js +0 -26
- package/commands/connect/mapping-write-errors.js +0 -34
- package/commands/connect/sf-auth.js +0 -76
- package/commands/connect-events/db-set.js +0 -68
- package/commands/connect-events/stream-create.js +0 -32
- package/commands/connect-events/stream-delete.js +0 -33
- package/commands/connect-events/stream-state.js +0 -26
- package/index.js +0 -50
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as api from '../../../lib/connect/api.js'
|
|
2
|
+
import cli from '@heroku/heroku-cli-util'
|
|
3
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
4
|
+
|
|
5
|
+
export function formatDate (date) {
|
|
6
|
+
if (!date) return ''
|
|
7
|
+
const d = new Date(date)
|
|
8
|
+
return d.toLocaleString('en-US', {
|
|
9
|
+
year: 'numeric',
|
|
10
|
+
month: '2-digit',
|
|
11
|
+
day: '2-digit',
|
|
12
|
+
hour: '2-digit',
|
|
13
|
+
minute: '2-digit'
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function truncateMessage (message, maxLength = 50) {
|
|
18
|
+
if (!message) return ''
|
|
19
|
+
if (message.length <= maxLength) return message
|
|
20
|
+
return message.substring(0, maxLength - 3) + '...'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default class Notifications extends Command {
|
|
24
|
+
static description = 'Return the unacknowledged notifications'
|
|
25
|
+
|
|
26
|
+
static flags = {
|
|
27
|
+
app: flags.app({ required: true }),
|
|
28
|
+
after: flags.string({ description: 'start date for notifications' }),
|
|
29
|
+
before: flags.string({ description: 'end date for notifications' }),
|
|
30
|
+
'event-type': flags.string({ description: 'type of event to filter by' }),
|
|
31
|
+
resource: flags.string({ description: 'specific connection resource name' })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async run () {
|
|
35
|
+
const { args, flags } = await this.parse(Notifications)
|
|
36
|
+
const context = { app: flags.app, flags, args, auth: { password: this.heroku.auth } }
|
|
37
|
+
|
|
38
|
+
const connection = await api.withConnection(context, this.heroku)
|
|
39
|
+
context.region = connection.region_url
|
|
40
|
+
|
|
41
|
+
const params = {
|
|
42
|
+
page_size: 1000,
|
|
43
|
+
after: context.flags.after,
|
|
44
|
+
before: context.flags.before,
|
|
45
|
+
event_type: context.flags['event-type']
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const response = await api.request(context, 'GET', '/api/v3/connections/' + connection.id + '/notifications', null, params)
|
|
49
|
+
cli.table(response.data.results, {
|
|
50
|
+
columns: [
|
|
51
|
+
{ key: 'event_type', label: 'Event Type' },
|
|
52
|
+
{ key: 'message', label: 'Message', format: (message) => truncateMessage(message, 50) },
|
|
53
|
+
{ key: 'created_at', label: 'Created At (MM/DD/YYYY HH:MM AM/PM)', format: formatDate }
|
|
54
|
+
]
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const co = require('co')
|
|
1
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
2
|
+
import cli from '@heroku/heroku-cli-util'
|
|
3
|
+
import * as api from '../../lib/connect/api.js'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
export default class ConnectPause extends Command {
|
|
6
|
+
static description = 'Pause a connection'
|
|
7
|
+
|
|
8
|
+
static flags = {
|
|
9
|
+
app: flags.app({ required: true }),
|
|
10
|
+
resource: flags.string({ description: 'specific connection resource name' })
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async run () {
|
|
14
|
+
const { flags } = await this.parse(ConnectPause)
|
|
15
|
+
const context = {
|
|
16
|
+
app: flags.app,
|
|
17
|
+
flags,
|
|
18
|
+
args: {},
|
|
19
|
+
auth: { password: this.heroku.auth }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
await cli.action('pausing connection', (async function () {
|
|
23
|
+
const connection = await api.withConnection(context, this.heroku)
|
|
19
24
|
context.region = connection.region_url
|
|
20
25
|
const url = '/api/v3/connections/' + connection.id + '/actions/pause'
|
|
21
|
-
|
|
22
|
-
}))
|
|
23
|
-
}
|
|
26
|
+
await api.request(context, 'POST', url)
|
|
27
|
+
}.bind(this))())
|
|
28
|
+
}
|
|
24
29
|
}
|
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const co = require('co')
|
|
1
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
2
|
+
import cli from '@heroku/heroku-cli-util'
|
|
3
|
+
import * as api from '../../lib/connect/api.js'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
aliases
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
export default class ConnectRecover extends Command {
|
|
6
|
+
static description = 'Recover a connection'
|
|
7
|
+
|
|
8
|
+
static aliases = ['connect:restart']
|
|
9
|
+
|
|
10
|
+
static flags = {
|
|
11
|
+
app: flags.app({ required: true }),
|
|
12
|
+
resource: flags.string({ description: 'specific connection resource name' })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async run () {
|
|
16
|
+
const { flags } = await this.parse(ConnectRecover)
|
|
17
|
+
const context = {
|
|
18
|
+
app: flags.app,
|
|
19
|
+
flags,
|
|
20
|
+
args: {},
|
|
21
|
+
auth: { password: this.heroku.auth }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await cli.action('recovering connection', (async function () {
|
|
25
|
+
const connection = await api.withConnection(context, this.heroku)
|
|
20
26
|
context.region = connection.region_url
|
|
21
27
|
const url = '/api/v3/connections/' + connection.id + '/actions/restart'
|
|
22
|
-
|
|
23
|
-
}))
|
|
24
|
-
}
|
|
28
|
+
await api.request(context, 'POST', url)
|
|
29
|
+
}.bind(this))())
|
|
30
|
+
}
|
|
25
31
|
}
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const co = require('co')
|
|
1
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
2
|
+
import cli from '@heroku/heroku-cli-util'
|
|
3
|
+
import * as api from '../../lib/connect/api.js'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
export default class ConnectResume extends Command {
|
|
6
|
+
static description = 'Resume a connection'
|
|
7
|
+
|
|
8
|
+
static flags = {
|
|
9
|
+
app: flags.app({ required: true }),
|
|
10
|
+
resource: flags.string({ description: 'specific connection resource name' })
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async run () {
|
|
14
|
+
const { flags } = await this.parse(ConnectResume)
|
|
15
|
+
const context = {
|
|
16
|
+
app: flags.app,
|
|
17
|
+
flags,
|
|
18
|
+
args: {},
|
|
19
|
+
auth: { password: this.heroku.auth }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
await cli.action('resuming connection', (async function () {
|
|
23
|
+
const connection = await api.withConnection(context, this.heroku)
|
|
19
24
|
context.region = connection.region_url
|
|
20
25
|
const url = '/api/v3/connections/' + connection.id + '/actions/resume'
|
|
21
|
-
|
|
22
|
-
}))
|
|
23
|
-
}
|
|
26
|
+
await api.request(context, 'POST', url)
|
|
27
|
+
}.bind(this))())
|
|
28
|
+
}
|
|
24
29
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as api from '../../../lib/connect/api.js'
|
|
2
|
+
import cli from '@heroku/heroku-cli-util'
|
|
3
|
+
import http from 'http'
|
|
4
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
5
|
+
|
|
6
|
+
const LOCAL_PORT = 18000
|
|
7
|
+
|
|
8
|
+
export function callbackServer () {
|
|
9
|
+
return new Promise(function (resolve, reject) {
|
|
10
|
+
// Create a local server that can receive the user after authoriztion is complete
|
|
11
|
+
http.createServer(function (request, response) {
|
|
12
|
+
// Notify the user that the the authorization is complete
|
|
13
|
+
response.writeHead(200, { 'Content-Type': 'text/html' })
|
|
14
|
+
const res = '<html><body><h3>Authorization complete</h3><p>You may close this window and return to the terminal to continue.</p></body></html>'
|
|
15
|
+
response.end(res)
|
|
16
|
+
|
|
17
|
+
// Shut down the server so the command can exit
|
|
18
|
+
request.socket.destroy()
|
|
19
|
+
this.close()
|
|
20
|
+
|
|
21
|
+
// Return control to the main command
|
|
22
|
+
resolve()
|
|
23
|
+
}).listen(LOCAL_PORT)
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default class SfAuth extends Command {
|
|
28
|
+
static description = 'Authorize access to Salesforce for your connection'
|
|
29
|
+
|
|
30
|
+
static callbackServer = callbackServer
|
|
31
|
+
|
|
32
|
+
static flags = {
|
|
33
|
+
app: flags.app({ required: true }),
|
|
34
|
+
callback: flags.string({ char: 'c', description: 'final callback URL' }),
|
|
35
|
+
environment: flags.string({ char: 'e', description: '"production", "sandbox", or "custom" [defaults to "production"]' }),
|
|
36
|
+
domain: flags.string({ char: 'd', description: 'specify a custom login domain (if using a "custom" environment)' }),
|
|
37
|
+
resource: flags.string({ description: 'specific connection resource name' })
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async run () {
|
|
41
|
+
const { args, flags } = await this.parse(SfAuth)
|
|
42
|
+
const context = { app: flags.app, flags, args, auth: { password: this.heroku.auth } }
|
|
43
|
+
|
|
44
|
+
let redir
|
|
45
|
+
await cli.action('fetching authorizing URL', (async function () {
|
|
46
|
+
const connection = await api.withConnection(context, this.heroku)
|
|
47
|
+
context.region = connection.region_url
|
|
48
|
+
|
|
49
|
+
const url = `/api/v3/connections/${connection.id}/authorize_url`
|
|
50
|
+
const args = {
|
|
51
|
+
environment: 'production',
|
|
52
|
+
// Redirect to the local server created in callbackServer(), so the CLI
|
|
53
|
+
// can respond immediately after successful authorization
|
|
54
|
+
next: `http://localhost:${LOCAL_PORT}`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (context.flags.environment) {
|
|
58
|
+
args.environment = context.flags.environment
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (context.flags.environment === 'custom' && context.flags.domain) {
|
|
62
|
+
args.domain = context.flags.domain
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const response = await api.request(context, 'POST', url, args)
|
|
66
|
+
redir = response.data.redirect
|
|
67
|
+
|
|
68
|
+
await cli.open(redir)
|
|
69
|
+
}.bind(this))())
|
|
70
|
+
|
|
71
|
+
cli.log("\nIf your browser doesn't open, please copy the following URL to proceed:\n" + redir + '\n')
|
|
72
|
+
|
|
73
|
+
await cli.action('waiting for authorization', SfAuth.callbackServer())
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,34 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const co = require('co')
|
|
1
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
2
|
+
import cli from '@heroku/heroku-cli-util'
|
|
3
|
+
import * as api from '../../lib/connect/api.js'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export default class ConnectState extends Command {
|
|
6
|
+
static description = 'return the connection(s) state'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
columns: [
|
|
14
|
-
{ key: 'db_key', label: 'Database' },
|
|
15
|
-
{ key: 'schema_name', label: 'Schema' },
|
|
16
|
-
{ key: 'state', label: 'State' }
|
|
17
|
-
]
|
|
18
|
-
})
|
|
8
|
+
static flags = {
|
|
9
|
+
app: flags.app({ required: true }),
|
|
10
|
+
resource: flags.string({ description: 'specific connection resource name' }),
|
|
11
|
+
json: flags.boolean({ description: 'print output as json' })
|
|
19
12
|
}
|
|
20
|
-
}
|
|
21
13
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
async run () {
|
|
15
|
+
const { flags } = await this.parse(ConnectState)
|
|
16
|
+
const context = {
|
|
17
|
+
app: flags.app,
|
|
18
|
+
flags,
|
|
19
|
+
args: {},
|
|
20
|
+
auth: { password: this.heroku.auth }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const connections = await api.withUserConnections(context, flags.app, flags, this.heroku)
|
|
24
|
+
|
|
25
|
+
if (flags.json) {
|
|
26
|
+
cli.styledJSON(connections)
|
|
27
|
+
} else {
|
|
28
|
+
cli.table(connections, {
|
|
29
|
+
columns: [
|
|
30
|
+
{ key: 'db_key', label: 'Database' },
|
|
31
|
+
{ key: 'schema_name', label: 'Schema' },
|
|
32
|
+
{ key: 'state', label: 'State' }
|
|
33
|
+
]
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
34
37
|
}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const cli = require('@heroku/heroku-cli-util')
|
|
1
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
2
|
+
import * as api from '../../lib/connect/api.js'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
examples: [
|
|
4
|
+
export default class ConnectWriteErrors extends Command {
|
|
5
|
+
static description = 'Display the last 24 hours of write errors on this connection'
|
|
6
|
+
|
|
7
|
+
static examples = [
|
|
10
8
|
'$ heroku connect:write-errors -a myapp --resource herokuconnect-twisted-123'
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
static flags = {
|
|
12
|
+
app: flags.app({ required: true }),
|
|
13
|
+
resource: flags.string({ description: 'specific connection resource name' }),
|
|
14
|
+
json: flags.boolean({ description: 'print errors as styled JSON' })
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async run () {
|
|
18
|
+
const { flags } = await this.parse(ConnectWriteErrors)
|
|
19
|
+
const context = {
|
|
20
|
+
app: flags.app,
|
|
21
|
+
flags,
|
|
22
|
+
args: {},
|
|
23
|
+
auth: { password: this.heroku.auth }
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
run: cli.command(api.getWriteErrors)
|
|
25
|
+
|
|
26
|
+
await api.getWriteErrors(context, this.heroku)
|
|
27
|
+
}
|
|
27
28
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as api from '../../../lib/connect/api.js'
|
|
2
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
3
|
+
import cli from '@heroku/heroku-cli-util'
|
|
4
|
+
import inquirer from 'inquirer'
|
|
5
|
+
|
|
6
|
+
async function fetchKeys (appName, context) {
|
|
7
|
+
const url = `/api/v3/apps/${appName}`
|
|
8
|
+
const response = await api.request(context, 'GET', url)
|
|
9
|
+
const keys = []
|
|
10
|
+
response.data.db_keys.forEach(function (key) {
|
|
11
|
+
keys.push({
|
|
12
|
+
name: `${key.name} (${key.addon.plan})`,
|
|
13
|
+
value: key.name
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
return keys
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default class ConnectEventsDbSet extends Command {
|
|
20
|
+
static description = 'Set database parameters'
|
|
21
|
+
|
|
22
|
+
static flags = {
|
|
23
|
+
app: flags.app({ required: true }),
|
|
24
|
+
resource: flags.string({ description: 'specific connection resource name' }),
|
|
25
|
+
db: flags.string({ description: 'Database config var name' }),
|
|
26
|
+
schema: flags.string({ description: 'Database schema name' })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async run () {
|
|
30
|
+
const { flags } = await this.parse(ConnectEventsDbSet)
|
|
31
|
+
const context = {
|
|
32
|
+
app: flags.app,
|
|
33
|
+
flags,
|
|
34
|
+
auth: { password: this.heroku.auth }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const data = {
|
|
38
|
+
db_key: flags.db,
|
|
39
|
+
schema_name: flags.schema
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const connection = await api.withConnection(context, this.heroku, api.ADDON_TYPE_EVENTS)
|
|
43
|
+
context.region = connection.region_url
|
|
44
|
+
|
|
45
|
+
const answers = await inquirer.prompt([
|
|
46
|
+
{
|
|
47
|
+
name: 'db_key',
|
|
48
|
+
type: 'list',
|
|
49
|
+
message: "Select the config var that points to the database you'd like to use",
|
|
50
|
+
choices: await fetchKeys(connection.app_name, context),
|
|
51
|
+
when: !flags.db
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'schema_name',
|
|
55
|
+
message: "Enter a schema name you'd like to use for the conneted data",
|
|
56
|
+
default: flags.schema || 'salesforce',
|
|
57
|
+
when: !flags.schema
|
|
58
|
+
}
|
|
59
|
+
])
|
|
60
|
+
|
|
61
|
+
for (const key in answers) {
|
|
62
|
+
data[key] = answers[key]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
await cli.action('setting database parameters', (async function () {
|
|
66
|
+
const url = `/api/v3/kafka-connections/${connection.id}`
|
|
67
|
+
await api.request(context, 'PUT', url, data)
|
|
68
|
+
})())
|
|
69
|
+
|
|
70
|
+
cli.styledHash(data)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as api from '../../lib/connect/api.js'
|
|
2
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
3
|
+
import cli from '@heroku/heroku-cli-util'
|
|
4
|
+
|
|
5
|
+
export default class ConnectEventsInfo extends Command {
|
|
6
|
+
static description = 'display connection information'
|
|
7
|
+
|
|
8
|
+
static flags = {
|
|
9
|
+
app: flags.app({ required: true }),
|
|
10
|
+
resource: flags.string({ description: 'specific connection resource name' }),
|
|
11
|
+
'check-for-new': flags.boolean({ char: 'c', description: 'check for access to any new connections' })
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async run () {
|
|
15
|
+
const { flags } = await this.parse(ConnectEventsInfo)
|
|
16
|
+
const context = {
|
|
17
|
+
app: flags.app,
|
|
18
|
+
flags,
|
|
19
|
+
auth: { password: this.heroku.auth }
|
|
20
|
+
}
|
|
5
21
|
|
|
6
|
-
module.exports = {
|
|
7
|
-
topic: 'connect-events',
|
|
8
|
-
command: 'info',
|
|
9
|
-
default: false,
|
|
10
|
-
description: 'display connection information',
|
|
11
|
-
help: 'display connection information',
|
|
12
|
-
flags: [
|
|
13
|
-
{ name: 'resource', description: 'specific connection resource name', hasValue: true },
|
|
14
|
-
{ name: 'check-for-new', char: 'c', description: 'check for access to any new connections', hasValue: false }
|
|
15
|
-
],
|
|
16
|
-
needsApp: true,
|
|
17
|
-
needsAuth: true,
|
|
18
|
-
run: cli.command(co.wrap(function * (context, heroku) {
|
|
19
22
|
let connections
|
|
20
23
|
|
|
21
|
-
if (
|
|
22
|
-
connections =
|
|
24
|
+
if (flags['check-for-new']) {
|
|
25
|
+
connections = await api.requestAppAccess(context, flags.app, flags, true, this.heroku, api.ADDON_TYPE_EVENTS)
|
|
23
26
|
} else {
|
|
24
|
-
connections =
|
|
27
|
+
connections = await api.withUserConnections(context, flags.app, flags, true, this.heroku, api.ADDON_TYPE_EVENTS)
|
|
25
28
|
if (connections.length === 0) {
|
|
26
|
-
connections =
|
|
29
|
+
connections = await api.requestAppAcess(context, flags.app, flags, true, this.heroku, api.ADDON_TYPE_EVENTS)
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -32,9 +35,9 @@ module.exports = {
|
|
|
32
35
|
cli.error('No connection found. You may need to use addons:open to make it accessible to the CLI.')
|
|
33
36
|
cli.error('')
|
|
34
37
|
cli.error('For Example:')
|
|
35
|
-
cli.error(`heroku addons:open ${instanceName} -a ${
|
|
38
|
+
cli.error(`heroku addons:open ${instanceName} -a ${flags.app}`)
|
|
36
39
|
} else {
|
|
37
|
-
connections =
|
|
40
|
+
connections = await api.withStreams(context, connections)
|
|
38
41
|
connections.forEach(function (connection) {
|
|
39
42
|
cli.styledHeader(`Connection [${connection.id}] / ${connection.resource_name} (${connection.state})`)
|
|
40
43
|
cli.log()
|
|
@@ -53,5 +56,5 @@ module.exports = {
|
|
|
53
56
|
cli.log()
|
|
54
57
|
})
|
|
55
58
|
}
|
|
56
|
-
}
|
|
59
|
+
}
|
|
57
60
|
}
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const co = require('co')
|
|
1
|
+
import * as api from '../../lib/connect/api.js'
|
|
2
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
3
|
+
import cli from '@heroku/heroku-cli-util'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
export default class ConnectEventsPause extends Command {
|
|
6
|
+
static description = 'Pause a connection'
|
|
7
|
+
|
|
8
|
+
static flags = {
|
|
9
|
+
app: flags.app({ required: true }),
|
|
10
|
+
resource: flags.string({ description: 'specific connection resource name' })
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async run () {
|
|
14
|
+
const { flags } = await this.parse(ConnectEventsPause)
|
|
15
|
+
const context = {
|
|
16
|
+
app: flags.app,
|
|
17
|
+
flags,
|
|
18
|
+
auth: { password: this.heroku.auth }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
await cli.action('pausing connection', (async function () {
|
|
22
|
+
const connection = await api.withConnection(context, this.heroku, api.ADDON_TYPE_EVENTS)
|
|
19
23
|
context.region = connection.region_url
|
|
20
24
|
const url = `/api/v3/kafka-connections/${connection.id}/actions/pause`
|
|
21
|
-
|
|
22
|
-
}))
|
|
23
|
-
}
|
|
25
|
+
await api.request(context, 'POST', url)
|
|
26
|
+
}.bind(this))())
|
|
27
|
+
}
|
|
24
28
|
}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const co = require('co')
|
|
1
|
+
import * as api from '../../lib/connect/api.js'
|
|
2
|
+
import { Command, flags } from '@heroku-cli/command'
|
|
3
|
+
import cli from '@heroku/heroku-cli-util'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
aliases
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
export default class ConnectEventsRecover extends Command {
|
|
6
|
+
static description = 'Recover a connection'
|
|
7
|
+
|
|
8
|
+
static aliases = ['connect:restart']
|
|
9
|
+
|
|
10
|
+
static flags = {
|
|
11
|
+
app: flags.app({ required: true }),
|
|
12
|
+
resource: flags.string({ description: 'specific connection resource name' })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async run () {
|
|
16
|
+
const { flags } = await this.parse(ConnectEventsRecover)
|
|
17
|
+
const context = {
|
|
18
|
+
app: flags.app,
|
|
19
|
+
flags,
|
|
20
|
+
auth: { password: this.heroku.auth }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
await cli.action('recovering connection', (async function () {
|
|
24
|
+
const connection = await api.withConnection(context, this.heroku, api.ADDON_TYPE_EVENTS)
|
|
20
25
|
context.region = connection.region_url
|
|
21
26
|
const url = `/api/v3/kafka-connections/${connection.id}/actions/recover`
|
|
22
|
-
|
|
23
|
-
}))
|
|
24
|
-
}
|
|
27
|
+
await api.request(context, 'POST', url)
|
|
28
|
+
}.bind(this))())
|
|
29
|
+
}
|
|
25
30
|
}
|