-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeactivate.ts
38 lines (29 loc) · 1.15 KB
/
deactivate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { flags, SfdxCommand } from '@salesforce/command';
import { singleRecordQuery } from '@mshanemc/plugin-helpers/dist/queries';
import { PushTopic } from '@mshanemc/plugin-helpers/dist/typeDefs';
export default class PushTopicUpsert extends SfdxCommand {
public static description = 'deactivate push topics';
public static aliases = ['shane:streaming:pushtopic:deactivate'];
public static examples = [`sfdx streaming:pushtopic:deactivate -n myTopic`];
protected static flagsConfig = {
name: flags.string({
char: 'n',
description: 'name for the push topic',
required: true
})
};
protected static requiresUsername = true;
public async run(): Promise<any> {
const conn = this.org.getConnection();
const existing = ((await singleRecordQuery({
conn,
query: `Select Id from PushTopic where Name='${this.flags.name}'`
})) as unknown) as PushTopic;
existing.IsActive = false;
const output = await conn.sobject('PushTopic').update(existing);
this.ux.log(`Deactivated`);
return {
output
};
}
}