Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit d2cc282

Browse files
authored
Merge pull request #310 from tinamatthews1/alerting-email
Alerting email
2 parents 9fee87d + bb1bb83 commit d2cc282

File tree

2 files changed

+431
-5
lines changed

2 files changed

+431
-5
lines changed

docs/alerting/api.md

Lines changed: 378 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,3 +858,381 @@ DELETE _opendistro/_alerting/destinations/<destination-id>
858858
"_primary_term": 1
859859
}
860860
```
861+
---
862+
863+
## Create email account
864+
865+
#### Request
866+
```json
867+
POST _opendistro/_alerting/destinations/email_accounts
868+
{
869+
"name": "example_account",
870+
"email": "[email protected]",
871+
"host": "smtp.email.com",
872+
"port": 465,
873+
"method": "ssl"
874+
}
875+
```
876+
877+
#### Sample response
878+
```json
879+
{
880+
"_id" : "email_account_id",
881+
"_version" : 1,
882+
"_seq_no" : 7,
883+
"_primary_term" : 2,
884+
"email_account" : {
885+
"schema_version" : 2,
886+
"name" : "example_account",
887+
"email" : "[email protected]",
888+
"host" : "smtp.email.com",
889+
"port" : 465,
890+
"method" : "ssl"
891+
}
892+
}
893+
```
894+
895+
## Update email account
896+
897+
#### Request
898+
```json
899+
PUT _opendistro/_alerting/destinations/email_accounts/<email_account_id>
900+
{
901+
"name": "example_account",
902+
"email": "[email protected]",
903+
"host": "smtp.email.com",
904+
"port": 465,
905+
"method": "ssl"
906+
}
907+
```
908+
#### Sample response
909+
```json
910+
{
911+
"_id" : "email_account_id",
912+
"_version" : 3,
913+
"_seq_no" : 19,
914+
"_primary_term" : 2,
915+
"email_account" : {
916+
"schema_version" : 2,
917+
"name" : "example_account",
918+
"email" : "[email protected]",
919+
"host" : "smtp.email.com",
920+
"port" : 465,
921+
"method" : "ssl"
922+
}
923+
}
924+
```
925+
926+
## Get email account
927+
928+
#### Request
929+
```json
930+
GET _opendistro/_alerting/destinations/email_accounts/<email_account_id>
931+
{
932+
"name": "example_account",
933+
"email": "[email protected]",
934+
"host": "smtp.email.com",
935+
"port": 465,
936+
"method": "ssl"
937+
}
938+
```
939+
#### Sample response
940+
```json
941+
{
942+
"_id" : "email_account_id",
943+
"_version" : 2,
944+
"_seq_no" : 8,
945+
"_primary_term" : 2,
946+
"email_account" : {
947+
"schema_version" : 2,
948+
"name" : "test_account",
949+
"email" : "[email protected]",
950+
"host" : "smtp.test.com",
951+
"port" : 465,
952+
"method" : "ssl"
953+
}
954+
}
955+
```
956+
957+
## Delete email account
958+
959+
#### Request
960+
```
961+
DELETE _opendistro/_alerting/destinations/email_accounts/<email_account_id>
962+
```
963+
#### Sample response
964+
965+
```json
966+
{
967+
"_index" : ".opendistro-alerting-config",
968+
"_type" : "_doc",
969+
"_id" : "email_account_id",
970+
"_version" : 1,
971+
"result" : "deleted",
972+
"forced_refresh" : true,
973+
"_shards" : {
974+
"total" : 2,
975+
"successful" : 2,
976+
"failed" : 0
977+
},
978+
"_seq_no" : 12,
979+
"_primary_term" : 2
980+
}
981+
```
982+
983+
## Search email account
984+
985+
#### Request
986+
987+
```json
988+
POST _opendistro/_alerting/destinations/email_accounts/_search
989+
{
990+
"from": 0,
991+
"size": 20,
992+
"sort": { "email_account.name.keyword": "desc" },
993+
"query": {
994+
"bool": {
995+
"must": {
996+
"match_all": {}
997+
}
998+
}
999+
}
1000+
}
1001+
```
1002+
1003+
#### Sample response
1004+
1005+
```json
1006+
{
1007+
"took" : 8,
1008+
"timed_out" : false,
1009+
"_shards" : {
1010+
"total" : 1,
1011+
"successful" : 1,
1012+
"skipped" : 0,
1013+
"failed" : 0
1014+
},
1015+
"hits" : {
1016+
"total" : {
1017+
"value" : 2,
1018+
"relation" : "eq"
1019+
},
1020+
"max_score" : null,
1021+
"hits" : [
1022+
{
1023+
"_index" : ".opendistro-alerting-config",
1024+
"_type" : "_doc",
1025+
"_id" : "email_account_id",
1026+
"_seq_no" : 8,
1027+
"_primary_term" : 2,
1028+
"_score" : null,
1029+
"_source" : {
1030+
"schema_version" : 2,
1031+
"name" : "example_account",
1032+
"email" : "[email protected]",
1033+
"host" : "smtp.email.com",
1034+
"port" : 465,
1035+
"method" : "ssl"
1036+
},
1037+
"sort" : [
1038+
"example_account"
1039+
]
1040+
},
1041+
...
1042+
]
1043+
}
1044+
}
1045+
```
1046+
1047+
---
1048+
1049+
## Create email group
1050+
1051+
#### Request
1052+
1053+
```json
1054+
POST _opendistro/_alerting/destinations/email_groups
1055+
{
1056+
"name": "example_email_group",
1057+
"emails": [{
1058+
"email": "[email protected]"
1059+
}]
1060+
}
1061+
```
1062+
1063+
#### Sample response
1064+
1065+
```json
1066+
{
1067+
"_id" : "email_group_id",
1068+
"_version" : 1,
1069+
"_seq_no" : 9,
1070+
"_primary_term" : 2,
1071+
"email_group" : {
1072+
"schema_version" : 2,
1073+
"name" : "example_email_group",
1074+
"emails" : [
1075+
{
1076+
"email" : "[email protected]"
1077+
}
1078+
]
1079+
}
1080+
}
1081+
```
1082+
1083+
## Update email group
1084+
1085+
#### Request
1086+
1087+
```json
1088+
PUT _opendistro/_alerting/destinations/email_groups/<email_group_id>
1089+
{
1090+
"name": "example_email_group",
1091+
"emails": [{
1092+
"email": "[email protected]"
1093+
}]
1094+
}
1095+
```
1096+
#### Sample response
1097+
1098+
```json
1099+
{
1100+
"_id" : "email_group_id",
1101+
"_version" : 4,
1102+
"_seq_no" : 17,
1103+
"_primary_term" : 2,
1104+
"email_group" : {
1105+
"schema_version" : 2,
1106+
"name" : "example_email_group",
1107+
"emails" : [
1108+
{
1109+
"email" : "[email protected]"
1110+
}
1111+
]
1112+
}
1113+
}
1114+
```
1115+
1116+
## Get email group
1117+
1118+
#### Request
1119+
```json
1120+
GET _opendistro/_alerting/destinations/email_groups/<email_group_id>
1121+
{
1122+
"name": "example_email_group",
1123+
"emails": [{
1124+
"email": "[email protected]"
1125+
}]
1126+
}
1127+
```
1128+
#### Sample response
1129+
1130+
```json
1131+
{
1132+
"_id" : "email_group_id",
1133+
"_version" : 4,
1134+
"_seq_no" : 17,
1135+
"_primary_term" : 2,
1136+
"email_group" : {
1137+
"schema_version" : 2,
1138+
"name" : "example_email_group",
1139+
"emails" : [
1140+
{
1141+
"email" : "[email protected]"
1142+
}
1143+
]
1144+
}
1145+
}
1146+
```
1147+
1148+
## Delete email group
1149+
1150+
#### Request
1151+
```
1152+
DELETE _opendistro/_alerting/destinations/email_groups/<email_group_id>
1153+
```
1154+
#### Sample response
1155+
1156+
```json
1157+
{
1158+
"_index" : ".opendistro-alerting-config",
1159+
"_type" : "_doc",
1160+
"_id" : "email_group_id",
1161+
"_version" : 1,
1162+
"result" : "deleted",
1163+
"forced_refresh" : true,
1164+
"_shards" : {
1165+
"total" : 2,
1166+
"successful" : 2,
1167+
"failed" : 0
1168+
},
1169+
"_seq_no" : 11,
1170+
"_primary_term" : 2
1171+
}
1172+
```
1173+
1174+
## Search email group
1175+
1176+
#### Request
1177+
1178+
```json
1179+
POST _opendistro/_alerting/destinations/email_groups/_search
1180+
{
1181+
"from": 0,
1182+
"size": 20,
1183+
"sort": { "email_group.name.keyword": "desc" },
1184+
"query": {
1185+
"bool": {
1186+
"must": {
1187+
"match_all": {}
1188+
}
1189+
}
1190+
}
1191+
}
1192+
```
1193+
1194+
#### Sample response
1195+
1196+
```json
1197+
{
1198+
"took" : 7,
1199+
"timed_out" : false,
1200+
"_shards" : {
1201+
"total" : 1,
1202+
"successful" : 1,
1203+
"skipped" : 0,
1204+
"failed" : 0
1205+
},
1206+
"hits" : {
1207+
"total" : {
1208+
"value" : 5,
1209+
"relation" : "eq"
1210+
},
1211+
"max_score" : null,
1212+
"hits" : [
1213+
{
1214+
"_index" : ".opendistro-alerting-config",
1215+
"_type" : "_doc",
1216+
"_id" : "email_group_id",
1217+
"_seq_no" : 10,
1218+
"_primary_term" : 2,
1219+
"_score" : null,
1220+
"_source" : {
1221+
"schema_version" : 2,
1222+
"name" : "example_email_group",
1223+
"emails" : [
1224+
{
1225+
"email" : "[email protected]"
1226+
}
1227+
]
1228+
},
1229+
"sort" : [
1230+
"example_email_group"
1231+
]
1232+
},
1233+
...
1234+
]
1235+
}
1236+
}
1237+
```
1238+
---

0 commit comments

Comments
 (0)