|
1 | | -import { Session } from './project' |
2 | | -import { WebhookAlertChannel, WebhookAlertChannelProps } from './webhook-alert-channel' |
| 1 | +import { WebhookAlertChannel } from './webhook-alert-channel' |
| 2 | +import { AlertChannelProps } from './alert-channel' |
3 | 3 |
|
4 | | -export interface MSTeamsAlertChannelProps extends WebhookAlertChannelProps { |
| 4 | +export interface MSTeamsAlertChannelProps extends AlertChannelProps { |
5 | 5 | /** |
6 | | - * The name of your MSTeams alert |
7 | | - */ |
| 6 | + * Friendly name to recognise the integration. |
| 7 | + * */ |
8 | 8 | name: string |
9 | 9 | /** |
10 | | - * The URL webhook to which to send updates. |
| 10 | + * The unique URL created by creating an integration in Microsoft Teams. |
| 11 | + * {@link https://www.checklyhq.com/docs/integrations/msteams/} |
11 | 12 | */ |
12 | 13 | url: string |
13 | 14 | } |
14 | 15 |
|
15 | 16 | /** |
16 | | - * Creates an MSTeams Alert Channel |
| 17 | + * Creates a Microsoft Teams Alert Channel |
17 | 18 | * |
18 | 19 | * @remarks |
19 | 20 | * |
20 | 21 | * This class make use of the Alert Channel endpoints. |
21 | 22 | */ |
22 | 23 | export class MSTeamsAlertChannel extends WebhookAlertChannel { |
23 | | - name: string |
24 | | - url: string |
25 | | - |
26 | 24 | /** |
27 | | - * Constructs the MSTeams Alert Channel instance |
| 25 | + * Constructs the Microsoft Teams Alert Channel instance |
28 | 26 | * |
29 | 27 | * @param logicalId unique project-scoped resource name identification |
30 | 28 | * @param props MSTeams alert channel configuration properties |
31 | | - * Fix following url: |
32 | | - * {@link https://checklyhq.com/docs/cli/constructs/#MSTeamsalertchannel Read more in the docs} |
| 29 | + * |
| 30 | + * {@link https://checklyhq.com/docs/cli/constructs/#msteamsalertchannel Read more in the docs} |
33 | 31 | */ |
34 | 32 | constructor (logicalId: string, props: MSTeamsAlertChannelProps) { |
35 | 33 | super(logicalId, props) |
36 | | - this.name = props.name |
37 | | - this.url = props.url |
38 | | - this.template = props.template || `{ |
39 | | - "type": "message", |
40 | | - "attachments": [ |
| 34 | + this.webhookType = 'WEBHOOK_MSTEAMS' |
| 35 | + this.method = 'POST' |
| 36 | + this.template = `{ |
| 37 | + "type":"message", |
| 38 | + "attachments":[ |
41 | 39 | { |
42 | | - "contentType": "application/vnd.microsoft.card.adaptive", |
43 | | - "contentUrl": null, |
44 | | - "content": { |
45 | | - "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", |
46 | | - "type": "AdaptiveCard", |
47 | | - "version": "1.2", |
48 | | - "body": [ |
| 40 | + "contentType":"application/vnd.microsoft.card.adaptive", |
| 41 | + "contentUrl":null, |
| 42 | + "content":{ |
| 43 | + "$schema":"http://adaptivecards.io/schemas/adaptive-card.json", |
| 44 | + "type":"AdaptiveCard", |
| 45 | + "version":"1.2", |
| 46 | + "body":[ |
49 | 47 | { |
50 | 48 | "type": "Container", |
51 | 49 | "items": [ |
@@ -96,27 +94,33 @@ export class MSTeamsAlertChannel extends WebhookAlertChannel { |
96 | 94 | ] |
97 | 95 | } |
98 | 96 | ], |
99 | | - "actions": [ |
| 97 | + "actions":[ |
100 | 98 | { |
101 | | - "type": "Action.OpenUrl", |
102 | | - "title": "View in Checkly", |
103 | | - "url": "{{RESULT_LINK}}" |
| 99 | + "type":"Action.OpenUrl", |
| 100 | + "title":"View in Checkly", |
| 101 | + "url":"{{RESULT_LINK}}" |
104 | 102 | } |
105 | 103 | ] |
106 | 104 | } |
107 | 105 | } |
108 | 106 | ] |
109 | | -}` |
110 | | - Session.registerConstruct(this) |
| 107 | +} |
| 108 | +` |
111 | 109 | } |
112 | 110 |
|
113 | 111 | synthesize () { |
114 | 112 | return { |
115 | 113 | ...super.synthesize(), |
116 | | - type: 'WEBHOOK_MSTEAMS', |
| 114 | + type: 'WEBHOOK', |
117 | 115 | config: { |
118 | 116 | name: this.name, |
| 117 | + webhookType: this.webhookType, |
119 | 118 | url: this.url, |
| 119 | + template: this.template, |
| 120 | + method: this.method, |
| 121 | + headers: this.headers, |
| 122 | + queryParameters: this.queryParameters, |
| 123 | + webhookSecret: this.webhookSecret, |
120 | 124 | }, |
121 | 125 | } |
122 | 126 | } |
|
0 commit comments