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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336
|
package metrics
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
)
// The package's fully qualified name.
const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-05-01-preview/metrics"
// AlertAction an alert action.
type AlertAction struct {
// ActionGroupID - the id of the action group to use.
ActionGroupID *string `json:"actionGroupId,omitempty"`
// WebHookProperties - This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook.
WebHookProperties map[string]*string `json:"webHookProperties"`
}
// MarshalJSON is the custom marshaler for AlertAction.
func (aa AlertAction) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if aa.ActionGroupID != nil {
objectMap["actionGroupId"] = aa.ActionGroupID
}
if aa.WebHookProperties != nil {
objectMap["webHookProperties"] = aa.WebHookProperties
}
return json.Marshal(objectMap)
}
// BasicAlertCriteria the rule criteria that defines the conditions of the alert rule.
type BasicAlertCriteria interface {
AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool)
AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool)
AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool)
AsAlertCriteria() (*AlertCriteria, bool)
}
// AlertCriteria the rule criteria that defines the conditions of the alert rule.
type AlertCriteria struct {
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
OdataType OdataType `json:"odata.type,omitempty"`
}
func unmarshalBasicAlertCriteria(body []byte) (BasicAlertCriteria, error) {
var m map[string]interface{}
err := json.Unmarshal(body, &m)
if err != nil {
return nil, err
}
switch m["odata.type"] {
case string(OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria):
var asrmmc AlertSingleResourceMultipleMetricCriteria
err := json.Unmarshal(body, &asrmmc)
return asrmmc, err
case string(OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria):
var wlac WebtestLocationAvailabilityCriteria
err := json.Unmarshal(body, &wlac)
return wlac, err
case string(OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria):
var amrmmc AlertMultipleResourceMultipleMetricCriteria
err := json.Unmarshal(body, &amrmmc)
return amrmmc, err
default:
var ac AlertCriteria
err := json.Unmarshal(body, &ac)
return ac, err
}
}
func unmarshalBasicAlertCriteriaArray(body []byte) ([]BasicAlertCriteria, error) {
var rawMessages []*json.RawMessage
err := json.Unmarshal(body, &rawMessages)
if err != nil {
return nil, err
}
acArray := make([]BasicAlertCriteria, len(rawMessages))
for index, rawMessage := range rawMessages {
ac, err := unmarshalBasicAlertCriteria(*rawMessage)
if err != nil {
return nil, err
}
acArray[index] = ac
}
return acArray, nil
}
// MarshalJSON is the custom marshaler for AlertCriteria.
func (ac AlertCriteria) MarshalJSON() ([]byte, error) {
ac.OdataType = OdataTypeMetricAlertCriteria
objectMap := make(map[string]interface{})
if ac.OdataType != "" {
objectMap["odata.type"] = ac.OdataType
}
for k, v := range ac.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
return nil, false
}
// AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsAlertCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
return &ac, true
}
// AsBasicAlertCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
return &ac, true
}
// UnmarshalJSON is the custom unmarshaler for AlertCriteria struct.
func (ac *AlertCriteria) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if ac.AdditionalProperties == nil {
ac.AdditionalProperties = make(map[string]interface{})
}
ac.AdditionalProperties[k] = additionalProperties
}
case "odata.type":
if v != nil {
var odataType OdataType
err = json.Unmarshal(*v, &odataType)
if err != nil {
return err
}
ac.OdataType = odataType
}
}
}
return nil
}
// AlertMultipleResourceMultipleMetricCriteria specifies the metric alert criteria for multiple resource
// that has multiple metric criteria.
type AlertMultipleResourceMultipleMetricCriteria struct {
// AllOf - the list of multiple metric criteria for this 'all of' operation.
AllOf *[]BasicMultiMetricCriteria `json:"allOf,omitempty"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
OdataType OdataType `json:"odata.type,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) {
amrmmc.OdataType = OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria
objectMap := make(map[string]interface{})
if amrmmc.AllOf != nil {
objectMap["allOf"] = amrmmc.AllOf
}
if amrmmc.OdataType != "" {
objectMap["odata.type"] = amrmmc.OdataType
}
for k, v := range amrmmc.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
return nil, false
}
// AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
return &amrmmc, true
}
// AsAlertCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
return nil, false
}
// AsBasicAlertCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
return &amrmmc, true
}
// UnmarshalJSON is the custom unmarshaler for AlertMultipleResourceMultipleMetricCriteria struct.
func (amrmmc *AlertMultipleResourceMultipleMetricCriteria) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "allOf":
if v != nil {
allOf, err := unmarshalBasicMultiMetricCriteriaArray(*v)
if err != nil {
return err
}
amrmmc.AllOf = &allOf
}
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if amrmmc.AdditionalProperties == nil {
amrmmc.AdditionalProperties = make(map[string]interface{})
}
amrmmc.AdditionalProperties[k] = additionalProperties
}
case "odata.type":
if v != nil {
var odataType OdataType
err = json.Unmarshal(*v, &odataType)
if err != nil {
return err
}
amrmmc.OdataType = odataType
}
}
}
return nil
}
// AlertProperties an alert rule.
type AlertProperties struct {
// Description - the description of the metric alert that will be included in the alert email.
Description *string `json:"description,omitempty"`
// Severity - Alert severity {0, 1, 2, 3, 4}
Severity *int32 `json:"severity,omitempty"`
// Enabled - the flag that indicates whether the metric alert is enabled.
Enabled *bool `json:"enabled,omitempty"`
// Scopes - the list of resource id's that this metric alert is scoped to.
Scopes *[]string `json:"scopes,omitempty"`
// EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format.
EvaluationFrequency *string `json:"evaluationFrequency,omitempty"`
// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.
WindowSize *string `json:"windowSize,omitempty"`
// TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource.
TargetResourceType *string `json:"targetResourceType,omitempty"`
// TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource.
TargetResourceRegion *string `json:"targetResourceRegion,omitempty"`
// Criteria - defines the specific alert criteria information.
Criteria BasicAlertCriteria `json:"criteria,omitempty"`
// AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true.
AutoMitigate *bool `json:"autoMitigate,omitempty"`
// Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
Actions *[]AlertAction `json:"actions,omitempty"`
// LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format.
LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"`
// IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated.
IsMigrated *bool `json:"isMigrated,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertProperties.
func (ap AlertProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ap.Description != nil {
objectMap["description"] = ap.Description
}
if ap.Severity != nil {
objectMap["severity"] = ap.Severity
}
if ap.Enabled != nil {
objectMap["enabled"] = ap.Enabled
}
if ap.Scopes != nil {
objectMap["scopes"] = ap.Scopes
}
if ap.EvaluationFrequency != nil {
objectMap["evaluationFrequency"] = ap.EvaluationFrequency
}
if ap.WindowSize != nil {
objectMap["windowSize"] = ap.WindowSize
}
if ap.TargetResourceType != nil {
objectMap["targetResourceType"] = ap.TargetResourceType
}
if ap.TargetResourceRegion != nil {
objectMap["targetResourceRegion"] = ap.TargetResourceRegion
}
objectMap["criteria"] = ap.Criteria
if ap.AutoMitigate != nil {
objectMap["autoMitigate"] = ap.AutoMitigate
}
if ap.Actions != nil {
objectMap["actions"] = ap.Actions
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertProperties struct.
func (ap *AlertProperties) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "description":
if v != nil {
var description string
err = json.Unmarshal(*v, &description)
if err != nil {
return err
}
ap.Description = &description
}
case "severity":
if v != nil {
var severity int32
err = json.Unmarshal(*v, &severity)
if err != nil {
return err
}
ap.Severity = &severity
}
case "enabled":
if v != nil {
var enabled bool
err = json.Unmarshal(*v, &enabled)
if err != nil {
return err
}
ap.Enabled = &enabled
}
case "scopes":
if v != nil {
var scopes []string
err = json.Unmarshal(*v, &scopes)
if err != nil {
return err
}
ap.Scopes = &scopes
}
case "evaluationFrequency":
if v != nil {
var evaluationFrequency string
err = json.Unmarshal(*v, &evaluationFrequency)
if err != nil {
return err
}
ap.EvaluationFrequency = &evaluationFrequency
}
case "windowSize":
if v != nil {
var windowSize string
err = json.Unmarshal(*v, &windowSize)
if err != nil {
return err
}
ap.WindowSize = &windowSize
}
case "targetResourceType":
if v != nil {
var targetResourceType string
err = json.Unmarshal(*v, &targetResourceType)
if err != nil {
return err
}
ap.TargetResourceType = &targetResourceType
}
case "targetResourceRegion":
if v != nil {
var targetResourceRegion string
err = json.Unmarshal(*v, &targetResourceRegion)
if err != nil {
return err
}
ap.TargetResourceRegion = &targetResourceRegion
}
case "criteria":
if v != nil {
criteria, err := unmarshalBasicAlertCriteria(*v)
if err != nil {
return err
}
ap.Criteria = criteria
}
case "autoMitigate":
if v != nil {
var autoMitigate bool
err = json.Unmarshal(*v, &autoMitigate)
if err != nil {
return err
}
ap.AutoMitigate = &autoMitigate
}
case "actions":
if v != nil {
var actions []AlertAction
err = json.Unmarshal(*v, &actions)
if err != nil {
return err
}
ap.Actions = &actions
}
case "lastUpdatedTime":
if v != nil {
var lastUpdatedTime date.Time
err = json.Unmarshal(*v, &lastUpdatedTime)
if err != nil {
return err
}
ap.LastUpdatedTime = &lastUpdatedTime
}
case "isMigrated":
if v != nil {
var isMigrated bool
err = json.Unmarshal(*v, &isMigrated)
if err != nil {
return err
}
ap.IsMigrated = &isMigrated
}
}
}
return nil
}
// AlertPropertiesPatch an alert rule properties for patch.
type AlertPropertiesPatch struct {
// Description - the description of the metric alert that will be included in the alert email.
Description *string `json:"description,omitempty"`
// Severity - Alert severity {0, 1, 2, 3, 4}
Severity *int32 `json:"severity,omitempty"`
// Enabled - the flag that indicates whether the metric alert is enabled.
Enabled *bool `json:"enabled,omitempty"`
// Scopes - the list of resource id's that this metric alert is scoped to.
Scopes *[]string `json:"scopes,omitempty"`
// EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format.
EvaluationFrequency *string `json:"evaluationFrequency,omitempty"`
// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.
WindowSize *string `json:"windowSize,omitempty"`
// TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.
TargetResourceType *string `json:"targetResourceType,omitempty"`
// TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.
TargetResourceRegion *string `json:"targetResourceRegion,omitempty"`
// Criteria - defines the specific alert criteria information.
Criteria BasicAlertCriteria `json:"criteria,omitempty"`
// AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true.
AutoMitigate *bool `json:"autoMitigate,omitempty"`
// Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
Actions *[]AlertAction `json:"actions,omitempty"`
// LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format.
LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"`
// IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated.
IsMigrated *bool `json:"isMigrated,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertPropertiesPatch.
func (app AlertPropertiesPatch) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if app.Description != nil {
objectMap["description"] = app.Description
}
if app.Severity != nil {
objectMap["severity"] = app.Severity
}
if app.Enabled != nil {
objectMap["enabled"] = app.Enabled
}
if app.Scopes != nil {
objectMap["scopes"] = app.Scopes
}
if app.EvaluationFrequency != nil {
objectMap["evaluationFrequency"] = app.EvaluationFrequency
}
if app.WindowSize != nil {
objectMap["windowSize"] = app.WindowSize
}
if app.TargetResourceType != nil {
objectMap["targetResourceType"] = app.TargetResourceType
}
if app.TargetResourceRegion != nil {
objectMap["targetResourceRegion"] = app.TargetResourceRegion
}
objectMap["criteria"] = app.Criteria
if app.AutoMitigate != nil {
objectMap["autoMitigate"] = app.AutoMitigate
}
if app.Actions != nil {
objectMap["actions"] = app.Actions
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertPropertiesPatch struct.
func (app *AlertPropertiesPatch) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "description":
if v != nil {
var description string
err = json.Unmarshal(*v, &description)
if err != nil {
return err
}
app.Description = &description
}
case "severity":
if v != nil {
var severity int32
err = json.Unmarshal(*v, &severity)
if err != nil {
return err
}
app.Severity = &severity
}
case "enabled":
if v != nil {
var enabled bool
err = json.Unmarshal(*v, &enabled)
if err != nil {
return err
}
app.Enabled = &enabled
}
case "scopes":
if v != nil {
var scopes []string
err = json.Unmarshal(*v, &scopes)
if err != nil {
return err
}
app.Scopes = &scopes
}
case "evaluationFrequency":
if v != nil {
var evaluationFrequency string
err = json.Unmarshal(*v, &evaluationFrequency)
if err != nil {
return err
}
app.EvaluationFrequency = &evaluationFrequency
}
case "windowSize":
if v != nil {
var windowSize string
err = json.Unmarshal(*v, &windowSize)
if err != nil {
return err
}
app.WindowSize = &windowSize
}
case "targetResourceType":
if v != nil {
var targetResourceType string
err = json.Unmarshal(*v, &targetResourceType)
if err != nil {
return err
}
app.TargetResourceType = &targetResourceType
}
case "targetResourceRegion":
if v != nil {
var targetResourceRegion string
err = json.Unmarshal(*v, &targetResourceRegion)
if err != nil {
return err
}
app.TargetResourceRegion = &targetResourceRegion
}
case "criteria":
if v != nil {
criteria, err := unmarshalBasicAlertCriteria(*v)
if err != nil {
return err
}
app.Criteria = criteria
}
case "autoMitigate":
if v != nil {
var autoMitigate bool
err = json.Unmarshal(*v, &autoMitigate)
if err != nil {
return err
}
app.AutoMitigate = &autoMitigate
}
case "actions":
if v != nil {
var actions []AlertAction
err = json.Unmarshal(*v, &actions)
if err != nil {
return err
}
app.Actions = &actions
}
case "lastUpdatedTime":
if v != nil {
var lastUpdatedTime date.Time
err = json.Unmarshal(*v, &lastUpdatedTime)
if err != nil {
return err
}
app.LastUpdatedTime = &lastUpdatedTime
}
case "isMigrated":
if v != nil {
var isMigrated bool
err = json.Unmarshal(*v, &isMigrated)
if err != nil {
return err
}
app.IsMigrated = &isMigrated
}
}
}
return nil
}
// AlertResource the metric alert resource.
type AlertResource struct {
autorest.Response `json:"-"`
// AlertProperties - The alert rule properties of the resource.
*AlertProperties `json:"properties,omitempty"`
// ID - READ-ONLY; Azure resource Id
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; Azure resource name
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; Azure resource type
Type *string `json:"type,omitempty"`
// Location - Resource location
Location *string `json:"location,omitempty"`
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for AlertResource.
func (ar AlertResource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ar.AlertProperties != nil {
objectMap["properties"] = ar.AlertProperties
}
if ar.Location != nil {
objectMap["location"] = ar.Location
}
if ar.Tags != nil {
objectMap["tags"] = ar.Tags
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertResource struct.
func (ar *AlertResource) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "properties":
if v != nil {
var alertProperties AlertProperties
err = json.Unmarshal(*v, &alertProperties)
if err != nil {
return err
}
ar.AlertProperties = &alertProperties
}
case "id":
if v != nil {
var ID string
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
ar.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
ar.Name = &name
}
case "type":
if v != nil {
var typeVar string
err = json.Unmarshal(*v, &typeVar)
if err != nil {
return err
}
ar.Type = &typeVar
}
case "location":
if v != nil {
var location string
err = json.Unmarshal(*v, &location)
if err != nil {
return err
}
ar.Location = &location
}
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
ar.Tags = tags
}
}
}
return nil
}
// AlertResourceCollection represents a collection of alert rule resources.
type AlertResourceCollection struct {
autorest.Response `json:"-"`
// Value - the values for the alert rule resources.
Value *[]AlertResource `json:"value,omitempty"`
}
// AlertResourcePatch the metric alert resource for patch operations.
type AlertResourcePatch struct {
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
// AlertPropertiesPatch - The alert rule properties of the resource.
*AlertPropertiesPatch `json:"properties,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertResourcePatch.
func (arp AlertResourcePatch) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if arp.Tags != nil {
objectMap["tags"] = arp.Tags
}
if arp.AlertPropertiesPatch != nil {
objectMap["properties"] = arp.AlertPropertiesPatch
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertResourcePatch struct.
func (arp *AlertResourcePatch) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
arp.Tags = tags
}
case "properties":
if v != nil {
var alertPropertiesPatch AlertPropertiesPatch
err = json.Unmarshal(*v, &alertPropertiesPatch)
if err != nil {
return err
}
arp.AlertPropertiesPatch = &alertPropertiesPatch
}
}
}
return nil
}
// AlertSingleResourceMultipleMetricCriteria specifies the metric alert criteria for a single resource that
// has multiple metric criteria.
type AlertSingleResourceMultipleMetricCriteria struct {
// AllOf - The list of metric criteria for this 'all of' operation.
AllOf *[]Criteria `json:"allOf,omitempty"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
OdataType OdataType `json:"odata.type,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) {
asrmmc.OdataType = OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria
objectMap := make(map[string]interface{})
if asrmmc.AllOf != nil {
objectMap["allOf"] = asrmmc.AllOf
}
if asrmmc.OdataType != "" {
objectMap["odata.type"] = asrmmc.OdataType
}
for k, v := range asrmmc.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
return &asrmmc, true
}
// AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
return nil, false
}
// AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsAlertCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
return nil, false
}
// AsBasicAlertCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
return &asrmmc, true
}
// UnmarshalJSON is the custom unmarshaler for AlertSingleResourceMultipleMetricCriteria struct.
func (asrmmc *AlertSingleResourceMultipleMetricCriteria) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "allOf":
if v != nil {
var allOf []Criteria
err = json.Unmarshal(*v, &allOf)
if err != nil {
return err
}
asrmmc.AllOf = &allOf
}
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if asrmmc.AdditionalProperties == nil {
asrmmc.AdditionalProperties = make(map[string]interface{})
}
asrmmc.AdditionalProperties[k] = additionalProperties
}
case "odata.type":
if v != nil {
var odataType OdataType
err = json.Unmarshal(*v, &odataType)
if err != nil {
return err
}
asrmmc.OdataType = odataType
}
}
}
return nil
}
// AlertStatus an alert status.
type AlertStatus struct {
// Name - The status name.
Name *string `json:"name,omitempty"`
// ID - The alert rule arm id.
ID *string `json:"id,omitempty"`
// Type - The extended resource type name.
Type *string `json:"type,omitempty"`
// Properties - The alert status properties of the metric alert status.
Properties *AlertStatusProperties `json:"properties,omitempty"`
}
// AlertStatusCollection represents a collection of alert rule resources.
type AlertStatusCollection struct {
autorest.Response `json:"-"`
// Value - the values for the alert rule resources.
Value *[]AlertStatus `json:"value,omitempty"`
}
// AlertStatusProperties an alert status properties.
type AlertStatusProperties struct {
// Dimensions - An object describing the type of the dimensions.
Dimensions map[string]*string `json:"dimensions"`
// Status - status value
Status *string `json:"status,omitempty"`
// Timestamp - UTC time when the status was checked.
Timestamp *date.Time `json:"timestamp,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertStatusProperties.
func (asp AlertStatusProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if asp.Dimensions != nil {
objectMap["dimensions"] = asp.Dimensions
}
if asp.Status != nil {
objectMap["status"] = asp.Status
}
if asp.Timestamp != nil {
objectMap["timestamp"] = asp.Timestamp
}
return json.Marshal(objectMap)
}
// Availability metric availability specifies the time grain (aggregation interval or frequency) and the
// retention period for that time grain.
type Availability struct {
// TimeGrain - the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc.
TimeGrain *string `json:"timeGrain,omitempty"`
// Retention - the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc.
Retention *string `json:"retention,omitempty"`
}
// BaselineMetadata represents a baseline metadata value.
type BaselineMetadata struct {
// Name - Name of the baseline metadata.
Name *string `json:"name,omitempty"`
// Value - Value of the baseline metadata.
Value *string `json:"value,omitempty"`
}
// BaselinesProperties the response to a metric baselines query.
type BaselinesProperties struct {
// Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested.
Timespan *string `json:"timespan,omitempty"`
// Interval - The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made.
Interval *string `json:"interval,omitempty"`
// Namespace - The namespace of the metrics been queried.
Namespace *string `json:"namespace,omitempty"`
// Baselines - The baseline for each time series that was queried.
Baselines *[]TimeSeriesBaseline `json:"baselines,omitempty"`
}
// BaselinesResponse a list of metric baselines.
type BaselinesResponse struct {
autorest.Response `json:"-"`
// Value - The list of metric baselines.
Value *[]SingleMetricBaseline `json:"value,omitempty"`
}
// Criteria criterion to filter metrics.
type Criteria struct {
// Operator - the criteria operator. Possible values include: 'OperatorEquals', 'OperatorGreaterThan', 'OperatorGreaterThanOrEqual', 'OperatorLessThan', 'OperatorLessThanOrEqual'
Operator Operator `json:"operator,omitempty"`
// Threshold - the criteria threshold value that activates the alert.
Threshold *float64 `json:"threshold,omitempty"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// Name - Name of the criteria.
Name *string `json:"name,omitempty"`
// MetricName - Name of the metric.
MetricName *string `json:"metricName,omitempty"`
// MetricNamespace - Namespace of the metric.
MetricNamespace *string `json:"metricNamespace,omitempty"`
// TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal'
TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"`
// Dimensions - List of dimension conditions.
Dimensions *[]Dimension `json:"dimensions,omitempty"`
// SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped.
SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"`
// CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion'
CriterionType CriterionType `json:"criterionType,omitempty"`
}
// MarshalJSON is the custom marshaler for Criteria.
func (c Criteria) MarshalJSON() ([]byte, error) {
c.CriterionType = CriterionTypeStaticThresholdCriterion
objectMap := make(map[string]interface{})
if c.Operator != "" {
objectMap["operator"] = c.Operator
}
if c.Threshold != nil {
objectMap["threshold"] = c.Threshold
}
if c.Name != nil {
objectMap["name"] = c.Name
}
if c.MetricName != nil {
objectMap["metricName"] = c.MetricName
}
if c.MetricNamespace != nil {
objectMap["metricNamespace"] = c.MetricNamespace
}
if c.TimeAggregation != "" {
objectMap["timeAggregation"] = c.TimeAggregation
}
if c.Dimensions != nil {
objectMap["dimensions"] = c.Dimensions
}
if c.SkipMetricValidation != nil {
objectMap["skipMetricValidation"] = c.SkipMetricValidation
}
if c.CriterionType != "" {
objectMap["criterionType"] = c.CriterionType
}
for k, v := range c.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsCriteria is the BasicMultiMetricCriteria implementation for Criteria.
func (c Criteria) AsCriteria() (*Criteria, bool) {
return &c, true
}
// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for Criteria.
func (c Criteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) {
return nil, false
}
// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for Criteria.
func (c Criteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) {
return nil, false
}
// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for Criteria.
func (c Criteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) {
return &c, true
}
// UnmarshalJSON is the custom unmarshaler for Criteria struct.
func (c *Criteria) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "operator":
if v != nil {
var operator Operator
err = json.Unmarshal(*v, &operator)
if err != nil {
return err
}
c.Operator = operator
}
case "threshold":
if v != nil {
var threshold float64
err = json.Unmarshal(*v, &threshold)
if err != nil {
return err
}
c.Threshold = &threshold
}
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if c.AdditionalProperties == nil {
c.AdditionalProperties = make(map[string]interface{})
}
c.AdditionalProperties[k] = additionalProperties
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
c.Name = &name
}
case "metricName":
if v != nil {
var metricName string
err = json.Unmarshal(*v, &metricName)
if err != nil {
return err
}
c.MetricName = &metricName
}
case "metricNamespace":
if v != nil {
var metricNamespace string
err = json.Unmarshal(*v, &metricNamespace)
if err != nil {
return err
}
c.MetricNamespace = &metricNamespace
}
case "timeAggregation":
if v != nil {
var timeAggregation AggregationTypeEnum
err = json.Unmarshal(*v, &timeAggregation)
if err != nil {
return err
}
c.TimeAggregation = timeAggregation
}
case "dimensions":
if v != nil {
var dimensions []Dimension
err = json.Unmarshal(*v, &dimensions)
if err != nil {
return err
}
c.Dimensions = &dimensions
}
case "skipMetricValidation":
if v != nil {
var skipMetricValidation bool
err = json.Unmarshal(*v, &skipMetricValidation)
if err != nil {
return err
}
c.SkipMetricValidation = &skipMetricValidation
}
case "criterionType":
if v != nil {
var criterionType CriterionType
err = json.Unmarshal(*v, &criterionType)
if err != nil {
return err
}
c.CriterionType = criterionType
}
}
}
return nil
}
// Definition metric definition class specifies the metadata for a metric.
type Definition struct {
// IsDimensionRequired - Flag to indicate whether the dimension is required.
IsDimensionRequired *bool `json:"isDimensionRequired,omitempty"`
// ResourceID - the resource identifier of the resource that emitted the metric.
ResourceID *string `json:"resourceId,omitempty"`
// Namespace - the namespace the metric belongs to.
Namespace *string `json:"namespace,omitempty"`
// Name - the name and the display name of the metric, i.e. it is a localizable string.
Name *LocalizableString `json:"name,omitempty"`
// DisplayDescription - Detailed description of this metric.
DisplayDescription *string `json:"displayDescription,omitempty"`
// Category - Custom category name for this metric.
Category *string `json:"category,omitempty"`
// MetricClass - The class of the metric. Possible values include: 'MetricClassAvailability', 'MetricClassTransactions', 'MetricClassErrors', 'MetricClassLatency', 'MetricClassSaturation'
MetricClass MetricClass `json:"metricClass,omitempty"`
// Unit - the unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond'
Unit MetricUnit `json:"unit,omitempty"`
// PrimaryAggregationType - the primary aggregation type value defining how to use the values for display. Possible values include: 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total'
PrimaryAggregationType AggregationType `json:"primaryAggregationType,omitempty"`
// SupportedAggregationTypes - the collection of what aggregation types are supported.
SupportedAggregationTypes *[]AggregationType `json:"supportedAggregationTypes,omitempty"`
// MetricAvailabilities - the collection of what aggregation intervals are available to be queried.
MetricAvailabilities *[]Availability `json:"metricAvailabilities,omitempty"`
// ID - the resource identifier of the metric definition.
ID *string `json:"id,omitempty"`
// Dimensions - the name and the display name of the dimension, i.e. it is a localizable string.
Dimensions *[]LocalizableString `json:"dimensions,omitempty"`
}
// DefinitionCollection represents collection of metric definitions.
type DefinitionCollection struct {
autorest.Response `json:"-"`
// Value - the values for the metric definitions.
Value *[]Definition `json:"value,omitempty"`
}
// Dimension specifies a metric dimension.
type Dimension struct {
// Name - Name of the dimension.
Name *string `json:"name,omitempty"`
// Operator - the dimension operator. Only 'Include' and 'Exclude' are supported
Operator *string `json:"operator,omitempty"`
// Values - list of dimension values.
Values *[]string `json:"values,omitempty"`
}
// DimensionProperties type of operation: get, read, delete, etc.
type DimensionProperties struct {
// Name - Name of dimension.
Name *string `json:"name,omitempty"`
// DisplayName - Display name of dimension.
DisplayName *string `json:"displayName,omitempty"`
// ToBeExportedForShoebox - Legacy usage, should not set.
ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"`
// IsHidden - When set, the dimension is hidden from the customer, used in conjunction with the defaultDimensionValues field below
IsHidden *bool `json:"isHidden,omitempty"`
// DefaultDimensionValues - Default dimension value to be sent down for the hidden dimension during query
DefaultDimensionValues interface{} `json:"defaultDimensionValues,omitempty"`
}
// DynamicMetricCriteria criterion for dynamic threshold.
type DynamicMetricCriteria struct {
// Operator - The operator used to compare the metric value against the threshold. Possible values include: 'GreaterThan', 'LessThan', 'GreaterOrLessThan'
Operator DynamicThresholdOperator `json:"operator,omitempty"`
// AlertSensitivity - The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Possible values include: 'DynamicThresholdSensitivityLow', 'DynamicThresholdSensitivityMedium', 'DynamicThresholdSensitivityHigh'
AlertSensitivity DynamicThresholdSensitivity `json:"alertSensitivity,omitempty"`
// FailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert.
FailingPeriods *DynamicThresholdFailingPeriods `json:"failingPeriods,omitempty"`
// IgnoreDataBefore - Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format)
IgnoreDataBefore *date.Time `json:"ignoreDataBefore,omitempty"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// Name - Name of the criteria.
Name *string `json:"name,omitempty"`
// MetricName - Name of the metric.
MetricName *string `json:"metricName,omitempty"`
// MetricNamespace - Namespace of the metric.
MetricNamespace *string `json:"metricNamespace,omitempty"`
// TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal'
TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"`
// Dimensions - List of dimension conditions.
Dimensions *[]Dimension `json:"dimensions,omitempty"`
// SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped.
SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"`
// CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion'
CriterionType CriterionType `json:"criterionType,omitempty"`
}
// MarshalJSON is the custom marshaler for DynamicMetricCriteria.
func (dmc DynamicMetricCriteria) MarshalJSON() ([]byte, error) {
dmc.CriterionType = CriterionTypeDynamicThresholdCriterion
objectMap := make(map[string]interface{})
if dmc.Operator != "" {
objectMap["operator"] = dmc.Operator
}
if dmc.AlertSensitivity != "" {
objectMap["alertSensitivity"] = dmc.AlertSensitivity
}
if dmc.FailingPeriods != nil {
objectMap["failingPeriods"] = dmc.FailingPeriods
}
if dmc.IgnoreDataBefore != nil {
objectMap["ignoreDataBefore"] = dmc.IgnoreDataBefore
}
if dmc.Name != nil {
objectMap["name"] = dmc.Name
}
if dmc.MetricName != nil {
objectMap["metricName"] = dmc.MetricName
}
if dmc.MetricNamespace != nil {
objectMap["metricNamespace"] = dmc.MetricNamespace
}
if dmc.TimeAggregation != "" {
objectMap["timeAggregation"] = dmc.TimeAggregation
}
if dmc.Dimensions != nil {
objectMap["dimensions"] = dmc.Dimensions
}
if dmc.SkipMetricValidation != nil {
objectMap["skipMetricValidation"] = dmc.SkipMetricValidation
}
if dmc.CriterionType != "" {
objectMap["criterionType"] = dmc.CriterionType
}
for k, v := range dmc.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria.
func (dmc DynamicMetricCriteria) AsCriteria() (*Criteria, bool) {
return nil, false
}
// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria.
func (dmc DynamicMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) {
return &dmc, true
}
// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria.
func (dmc DynamicMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) {
return nil, false
}
// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria.
func (dmc DynamicMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) {
return &dmc, true
}
// UnmarshalJSON is the custom unmarshaler for DynamicMetricCriteria struct.
func (dmc *DynamicMetricCriteria) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "operator":
if v != nil {
var operator DynamicThresholdOperator
err = json.Unmarshal(*v, &operator)
if err != nil {
return err
}
dmc.Operator = operator
}
case "alertSensitivity":
if v != nil {
var alertSensitivity DynamicThresholdSensitivity
err = json.Unmarshal(*v, &alertSensitivity)
if err != nil {
return err
}
dmc.AlertSensitivity = alertSensitivity
}
case "failingPeriods":
if v != nil {
var failingPeriods DynamicThresholdFailingPeriods
err = json.Unmarshal(*v, &failingPeriods)
if err != nil {
return err
}
dmc.FailingPeriods = &failingPeriods
}
case "ignoreDataBefore":
if v != nil {
var ignoreDataBefore date.Time
err = json.Unmarshal(*v, &ignoreDataBefore)
if err != nil {
return err
}
dmc.IgnoreDataBefore = &ignoreDataBefore
}
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if dmc.AdditionalProperties == nil {
dmc.AdditionalProperties = make(map[string]interface{})
}
dmc.AdditionalProperties[k] = additionalProperties
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
dmc.Name = &name
}
case "metricName":
if v != nil {
var metricName string
err = json.Unmarshal(*v, &metricName)
if err != nil {
return err
}
dmc.MetricName = &metricName
}
case "metricNamespace":
if v != nil {
var metricNamespace string
err = json.Unmarshal(*v, &metricNamespace)
if err != nil {
return err
}
dmc.MetricNamespace = &metricNamespace
}
case "timeAggregation":
if v != nil {
var timeAggregation AggregationTypeEnum
err = json.Unmarshal(*v, &timeAggregation)
if err != nil {
return err
}
dmc.TimeAggregation = timeAggregation
}
case "dimensions":
if v != nil {
var dimensions []Dimension
err = json.Unmarshal(*v, &dimensions)
if err != nil {
return err
}
dmc.Dimensions = &dimensions
}
case "skipMetricValidation":
if v != nil {
var skipMetricValidation bool
err = json.Unmarshal(*v, &skipMetricValidation)
if err != nil {
return err
}
dmc.SkipMetricValidation = &skipMetricValidation
}
case "criterionType":
if v != nil {
var criterionType CriterionType
err = json.Unmarshal(*v, &criterionType)
if err != nil {
return err
}
dmc.CriterionType = criterionType
}
}
}
return nil
}
// DynamicThresholdFailingPeriods the minimum number of violations required within the selected lookback
// time window required to raise an alert.
type DynamicThresholdFailingPeriods struct {
// NumberOfEvaluationPeriods - The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points.
NumberOfEvaluationPeriods *float64 `json:"numberOfEvaluationPeriods,omitempty"`
// MinFailingPeriodsToAlert - The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods.
MinFailingPeriodsToAlert *float64 `json:"minFailingPeriodsToAlert,omitempty"`
}
// ErrorContract common error response for all Azure Resource Manager APIs to return error details for
// failed operations. (This also follows the OData error response format.)
type ErrorContract struct {
// Error - The error object.
Error *ErrorResponse `json:"error,omitempty"`
}
// ErrorResponse describes the format of Error response.
type ErrorResponse struct {
// Code - Error code
Code *string `json:"code,omitempty"`
// Message - Error message indicating why the operation failed.
Message *string `json:"message,omitempty"`
}
// LocalizableString the localizable string class.
type LocalizableString struct {
// Value - the invariant value.
Value *string `json:"value,omitempty"`
// LocalizedValue - the locale specific value.
LocalizedValue *string `json:"localizedValue,omitempty"`
}
// LogSpecification log specification of operation.
type LogSpecification struct {
// Name - Name of log specification.
Name *string `json:"name,omitempty"`
// DisplayName - Display name of log specification.
DisplayName *string `json:"displayName,omitempty"`
// BlobDuration - Blob duration of specification.
BlobDuration *string `json:"blobDuration,omitempty"`
}
// MetadataValue represents a metric metadata value.
type MetadataValue struct {
// Name - the name of the metadata.
Name *LocalizableString `json:"name,omitempty"`
// Value - the value of the metadata.
Value *string `json:"value,omitempty"`
}
// Metric the result data of a query.
type Metric struct {
// ID - the metric Id.
ID *string `json:"id,omitempty"`
// Type - the resource type of the metric resource.
Type *string `json:"type,omitempty"`
// Name - the name and the display name of the metric, i.e. it is localizable string.
Name *LocalizableString `json:"name,omitempty"`
// DisplayDescription - Detailed description of this metric.
DisplayDescription *string `json:"displayDescription,omitempty"`
// ErrorCode - 'Success' or the error details on query failures for this metric.
ErrorCode *string `json:"errorCode,omitempty"`
// ErrorMessage - Error message encountered querying this specific metric.
ErrorMessage *string `json:"errorMessage,omitempty"`
// Unit - The unit of the metric. Possible values include: 'UnitCount', 'UnitBytes', 'UnitSeconds', 'UnitCountPerSecond', 'UnitBytesPerSecond', 'UnitPercent', 'UnitMilliSeconds', 'UnitByteSeconds', 'UnitUnspecified', 'UnitCores', 'UnitMilliCores', 'UnitNanoCores', 'UnitBitsPerSecond'
Unit Unit `json:"unit,omitempty"`
// Timeseries - the time series returned when a data query is performed.
Timeseries *[]TimeSeriesElement `json:"timeseries,omitempty"`
}
// BasicMultiMetricCriteria the types of conditions for a multi resource alert.
type BasicMultiMetricCriteria interface {
AsCriteria() (*Criteria, bool)
AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool)
AsMultiMetricCriteria() (*MultiMetricCriteria, bool)
}
// MultiMetricCriteria the types of conditions for a multi resource alert.
type MultiMetricCriteria struct {
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// Name - Name of the criteria.
Name *string `json:"name,omitempty"`
// MetricName - Name of the metric.
MetricName *string `json:"metricName,omitempty"`
// MetricNamespace - Namespace of the metric.
MetricNamespace *string `json:"metricNamespace,omitempty"`
// TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal'
TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"`
// Dimensions - List of dimension conditions.
Dimensions *[]Dimension `json:"dimensions,omitempty"`
// SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped.
SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"`
// CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion'
CriterionType CriterionType `json:"criterionType,omitempty"`
}
func unmarshalBasicMultiMetricCriteria(body []byte) (BasicMultiMetricCriteria, error) {
var m map[string]interface{}
err := json.Unmarshal(body, &m)
if err != nil {
return nil, err
}
switch m["criterionType"] {
case string(CriterionTypeStaticThresholdCriterion):
var c Criteria
err := json.Unmarshal(body, &c)
return c, err
case string(CriterionTypeDynamicThresholdCriterion):
var dmc DynamicMetricCriteria
err := json.Unmarshal(body, &dmc)
return dmc, err
default:
var mmc MultiMetricCriteria
err := json.Unmarshal(body, &mmc)
return mmc, err
}
}
func unmarshalBasicMultiMetricCriteriaArray(body []byte) ([]BasicMultiMetricCriteria, error) {
var rawMessages []*json.RawMessage
err := json.Unmarshal(body, &rawMessages)
if err != nil {
return nil, err
}
mmcArray := make([]BasicMultiMetricCriteria, len(rawMessages))
for index, rawMessage := range rawMessages {
mmc, err := unmarshalBasicMultiMetricCriteria(*rawMessage)
if err != nil {
return nil, err
}
mmcArray[index] = mmc
}
return mmcArray, nil
}
// MarshalJSON is the custom marshaler for MultiMetricCriteria.
func (mmc MultiMetricCriteria) MarshalJSON() ([]byte, error) {
mmc.CriterionType = CriterionTypeMultiMetricCriteria
objectMap := make(map[string]interface{})
if mmc.Name != nil {
objectMap["name"] = mmc.Name
}
if mmc.MetricName != nil {
objectMap["metricName"] = mmc.MetricName
}
if mmc.MetricNamespace != nil {
objectMap["metricNamespace"] = mmc.MetricNamespace
}
if mmc.TimeAggregation != "" {
objectMap["timeAggregation"] = mmc.TimeAggregation
}
if mmc.Dimensions != nil {
objectMap["dimensions"] = mmc.Dimensions
}
if mmc.SkipMetricValidation != nil {
objectMap["skipMetricValidation"] = mmc.SkipMetricValidation
}
if mmc.CriterionType != "" {
objectMap["criterionType"] = mmc.CriterionType
}
for k, v := range mmc.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria.
func (mmc MultiMetricCriteria) AsCriteria() (*Criteria, bool) {
return nil, false
}
// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria.
func (mmc MultiMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) {
return nil, false
}
// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria.
func (mmc MultiMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) {
return &mmc, true
}
// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria.
func (mmc MultiMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) {
return &mmc, true
}
// UnmarshalJSON is the custom unmarshaler for MultiMetricCriteria struct.
func (mmc *MultiMetricCriteria) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if mmc.AdditionalProperties == nil {
mmc.AdditionalProperties = make(map[string]interface{})
}
mmc.AdditionalProperties[k] = additionalProperties
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
mmc.Name = &name
}
case "metricName":
if v != nil {
var metricName string
err = json.Unmarshal(*v, &metricName)
if err != nil {
return err
}
mmc.MetricName = &metricName
}
case "metricNamespace":
if v != nil {
var metricNamespace string
err = json.Unmarshal(*v, &metricNamespace)
if err != nil {
return err
}
mmc.MetricNamespace = &metricNamespace
}
case "timeAggregation":
if v != nil {
var timeAggregation AggregationTypeEnum
err = json.Unmarshal(*v, &timeAggregation)
if err != nil {
return err
}
mmc.TimeAggregation = timeAggregation
}
case "dimensions":
if v != nil {
var dimensions []Dimension
err = json.Unmarshal(*v, &dimensions)
if err != nil {
return err
}
mmc.Dimensions = &dimensions
}
case "skipMetricValidation":
if v != nil {
var skipMetricValidation bool
err = json.Unmarshal(*v, &skipMetricValidation)
if err != nil {
return err
}
mmc.SkipMetricValidation = &skipMetricValidation
}
case "criterionType":
if v != nil {
var criterionType CriterionType
err = json.Unmarshal(*v, &criterionType)
if err != nil {
return err
}
mmc.CriterionType = criterionType
}
}
}
return nil
}
// Namespace metric namespace class specifies the metadata for a metric namespace.
type Namespace struct {
// ID - The ID of the metric namespace.
ID *string `json:"id,omitempty"`
// Type - The type of the namespace.
Type *string `json:"type,omitempty"`
// Name - The escaped name of the namespace.
Name *string `json:"name,omitempty"`
// Classification - Kind of namespace. Possible values include: 'Platform', 'Custom', 'Qos'
Classification NamespaceClassification `json:"classification,omitempty"`
// Properties - Properties which include the fully qualified namespace name.
Properties *NamespaceName `json:"properties,omitempty"`
}
// NamespaceCollection represents collection of metric namespaces.
type NamespaceCollection struct {
autorest.Response `json:"-"`
// Value - The values for the metric namespaces.
Value *[]Namespace `json:"value,omitempty"`
}
// NamespaceName the fully qualified metric namespace name.
type NamespaceName struct {
// MetricNamespaceName - The metric namespace name.
MetricNamespaceName *string `json:"metricNamespaceName,omitempty"`
}
// Operation microsoft Insights API operation definition.
type Operation struct {
// Name - Operation name: {provider}/{resource}/{operation}
Name *string `json:"name,omitempty"`
// IsDataAction - Property to specify whether the action is a data action.
IsDataAction *bool `json:"isDataAction,omitempty"`
// Display - Display metadata associated with the operation.
Display *OperationDisplay `json:"display,omitempty"`
// OperationProperties - Properties of operation, include metric specifications.
*OperationProperties `json:"properties,omitempty"`
}
// MarshalJSON is the custom marshaler for Operation.
func (o Operation) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if o.Name != nil {
objectMap["name"] = o.Name
}
if o.IsDataAction != nil {
objectMap["isDataAction"] = o.IsDataAction
}
if o.Display != nil {
objectMap["display"] = o.Display
}
if o.OperationProperties != nil {
objectMap["properties"] = o.OperationProperties
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for Operation struct.
func (o *Operation) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
o.Name = &name
}
case "isDataAction":
if v != nil {
var isDataAction bool
err = json.Unmarshal(*v, &isDataAction)
if err != nil {
return err
}
o.IsDataAction = &isDataAction
}
case "display":
if v != nil {
var display OperationDisplay
err = json.Unmarshal(*v, &display)
if err != nil {
return err
}
o.Display = &display
}
case "properties":
if v != nil {
var operationProperties OperationProperties
err = json.Unmarshal(*v, &operationProperties)
if err != nil {
return err
}
o.OperationProperties = &operationProperties
}
}
}
return nil
}
// OperationDisplay display metadata associated with the operation.
type OperationDisplay struct {
// Publisher - The publisher of this operation.
Publisher *string `json:"publisher,omitempty"`
// Provider - Service provider: Microsoft.Insights
Provider *string `json:"provider,omitempty"`
// Resource - Resource on which the operation is performed: AlertRules, Autoscale, etc.
Resource *string `json:"resource,omitempty"`
// Operation - Operation type: Read, write, delete, etc.
Operation *string `json:"operation,omitempty"`
// Description - The description of the operation.
Description *string `json:"description,omitempty"`
}
// OperationListResult result of the request to list Microsoft.Insights operations. It contains a list of
// operations and a URL link to get the next set of results.
type OperationListResult struct {
autorest.Response `json:"-"`
// Value - List of operations supported by the Microsoft.Insights provider.
Value *[]Operation `json:"value,omitempty"`
// NextLink - URL to get the next set of operation list results if there are any.
NextLink *string `json:"nextLink,omitempty"`
}
// OperationProperties properties of operation, include metric specifications.
type OperationProperties struct {
// ServiceSpecification - One property of operation, include metric specifications.
ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"`
}
// Resource an azure resource object
type Resource struct {
// ID - READ-ONLY; Azure resource Id
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; Azure resource name
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; Azure resource type
Type *string `json:"type,omitempty"`
// Location - Resource location
Location *string `json:"location,omitempty"`
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for Resource.
func (r Resource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if r.Location != nil {
objectMap["location"] = r.Location
}
if r.Tags != nil {
objectMap["tags"] = r.Tags
}
return json.Marshal(objectMap)
}
// Response the response to a metrics query.
type Response struct {
autorest.Response `json:"-"`
// Cost - The integer value representing the relative cost of the query.
Cost *float64 `json:"cost,omitempty"`
// Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested.
Timespan *string `json:"timespan,omitempty"`
// Interval - The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made.
Interval *string `json:"interval,omitempty"`
// Namespace - The namespace of the metrics being queried
Namespace *string `json:"namespace,omitempty"`
// Resourceregion - The region of the resource being queried for metrics.
Resourceregion *string `json:"resourceregion,omitempty"`
// Value - the value of the collection.
Value *[]Metric `json:"value,omitempty"`
}
// ServiceSpecification one property of operation, include log specifications.
type ServiceSpecification struct {
// LogSpecifications - Log specifications of operation.
LogSpecifications *[]LogSpecification `json:"logSpecifications,omitempty"`
// MetricSpecifications - Metric specifications of operation.
MetricSpecifications *[]Specification `json:"metricSpecifications,omitempty"`
// LegacyMetricSpecifications - Legacy Metric specifications for operation. Deprecated, do not use.
LegacyMetricSpecifications interface{} `json:"legacyMetricSpecifications,omitempty"`
}
// SingleBaseline the baseline values for a single sensitivity value.
type SingleBaseline struct {
// Sensitivity - the sensitivity of the baseline. Possible values include: 'Low', 'Medium', 'High'
Sensitivity BaselineSensitivity `json:"sensitivity,omitempty"`
// LowThresholds - The low thresholds of the baseline.
LowThresholds *[]float64 `json:"lowThresholds,omitempty"`
// HighThresholds - The high thresholds of the baseline.
HighThresholds *[]float64 `json:"highThresholds,omitempty"`
}
// SingleDimension the metric dimension name and value.
type SingleDimension struct {
// Name - Name of the dimension.
Name *string `json:"name,omitempty"`
// Value - Value of the dimension.
Value *string `json:"value,omitempty"`
}
// SingleMetricBaseline the baseline results of a single metric.
type SingleMetricBaseline struct {
// ID - The metric baseline Id.
ID *string `json:"id,omitempty"`
// Type - The resource type of the metric baseline resource.
Type *string `json:"type,omitempty"`
// Name - The name of the metric for which the baselines were retrieved.
Name *string `json:"name,omitempty"`
// BaselinesProperties - The metric baseline properties of the metric.
*BaselinesProperties `json:"properties,omitempty"`
}
// MarshalJSON is the custom marshaler for SingleMetricBaseline.
func (smb SingleMetricBaseline) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if smb.ID != nil {
objectMap["id"] = smb.ID
}
if smb.Type != nil {
objectMap["type"] = smb.Type
}
if smb.Name != nil {
objectMap["name"] = smb.Name
}
if smb.BaselinesProperties != nil {
objectMap["properties"] = smb.BaselinesProperties
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for SingleMetricBaseline struct.
func (smb *SingleMetricBaseline) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "id":
if v != nil {
var ID string
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
smb.ID = &ID
}
case "type":
if v != nil {
var typeVar string
err = json.Unmarshal(*v, &typeVar)
if err != nil {
return err
}
smb.Type = &typeVar
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
smb.Name = &name
}
case "properties":
if v != nil {
var baselinesProperties BaselinesProperties
err = json.Unmarshal(*v, &baselinesProperties)
if err != nil {
return err
}
smb.BaselinesProperties = &baselinesProperties
}
}
}
return nil
}
// Specification metric specification of operation.
type Specification struct {
// Name - The name of the metric.
Name *string `json:"name,omitempty"`
// DisplayName - Display name of the metric.
DisplayName *string `json:"displayName,omitempty"`
// DisplayDescription - Display description of the metric.
DisplayDescription *string `json:"displayDescription,omitempty"`
// Unit - The metric unit. Possible values include: Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores
Unit *string `json:"unit,omitempty"`
// AggregationType - The default metric aggregation type. Possible values include: Total,Average,Maximum,Minimum,Count
AggregationType *string `json:"aggregationType,omitempty"`
// SupportedAggregationTypes - The supported aggregation types for the metrics.
SupportedAggregationTypes *[]string `json:"supportedAggregationTypes,omitempty"`
// SupportedTimeGrainTypes - The supported time grain types for the metrics.
SupportedTimeGrainTypes *[]string `json:"supportedTimeGrainTypes,omitempty"`
// Availabilities - The supported time grain types for the metrics.
Availabilities *[]string `json:"availabilities,omitempty"`
// LockAggregationType - The metric lock aggregation type.
LockAggregationType *string `json:"lockAggregationType,omitempty"`
// Category - Category or type of metric.
Category *string `json:"category,omitempty"`
// Dimensions - The dimensions of metric.
Dimensions *[]DimensionProperties `json:"dimensions,omitempty"`
// FillGapWithZero - Property to specify whether to fill empty gaps with zero.
FillGapWithZero *bool `json:"fillGapWithZero,omitempty"`
// InternalMetricName - The internal metric name.
InternalMetricName *string `json:"internalMetricName,omitempty"`
}
// SubscriptionScopeMetric the result data of a query.
type SubscriptionScopeMetric struct {
// ID - the metric Id.
ID *string `json:"id,omitempty"`
// Type - the resource type of the metric resource.
Type *string `json:"type,omitempty"`
// Name - the name and the display name of the metric, i.e. it is localizable string.
Name *LocalizableString `json:"name,omitempty"`
// DisplayDescription - Detailed description of this metric.
DisplayDescription *string `json:"displayDescription,omitempty"`
// ErrorCode - 'Success' or the error details on query failures for this metric.
ErrorCode *string `json:"errorCode,omitempty"`
// ErrorMessage - Error message encountered querying this specific metric.
ErrorMessage *string `json:"errorMessage,omitempty"`
// Unit - The unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond'
Unit MetricUnit `json:"unit,omitempty"`
// Timeseries - the time series returned when a data query is performed.
Timeseries *[]TimeSeriesElement `json:"timeseries,omitempty"`
}
// SubscriptionScopeMetricDefinition metric definition class specifies the metadata for a metric.
type SubscriptionScopeMetricDefinition struct {
// IsDimensionRequired - Flag to indicate whether the dimension is required.
IsDimensionRequired *bool `json:"isDimensionRequired,omitempty"`
// ResourceID - the resource identifier of the resource that emitted the metric.
ResourceID *string `json:"resourceId,omitempty"`
// Namespace - the namespace the metric belongs to.
Namespace *string `json:"namespace,omitempty"`
// Name - the name and the display name of the metric, i.e. it is a localizable string.
Name *LocalizableString `json:"name,omitempty"`
// DisplayDescription - Detailed description of this metric.
DisplayDescription *string `json:"displayDescription,omitempty"`
// Category - Custom category name for this metric.
Category *string `json:"category,omitempty"`
// MetricClass - The class of the metric. Possible values include: 'MetricClassAvailability', 'MetricClassTransactions', 'MetricClassErrors', 'MetricClassLatency', 'MetricClassSaturation'
MetricClass MetricClass `json:"metricClass,omitempty"`
// Unit - the unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond'
Unit MetricUnit `json:"unit,omitempty"`
// PrimaryAggregationType - the primary aggregation type value defining how to use the values for display. Possible values include: 'MetricAggregationTypeNone', 'MetricAggregationTypeAverage', 'MetricAggregationTypeCount', 'MetricAggregationTypeMinimum', 'MetricAggregationTypeMaximum', 'MetricAggregationTypeTotal'
PrimaryAggregationType MetricAggregationType `json:"primaryAggregationType,omitempty"`
// SupportedAggregationTypes - the collection of what aggregation types are supported.
SupportedAggregationTypes *[]MetricAggregationType `json:"supportedAggregationTypes,omitempty"`
// MetricAvailabilities - the collection of what aggregation intervals are available to be queried.
MetricAvailabilities *[]Availability `json:"metricAvailabilities,omitempty"`
// ID - the resource identifier of the metric definition.
ID *string `json:"id,omitempty"`
// Dimensions - the name and the display name of the dimension, i.e. it is a localizable string.
Dimensions *[]LocalizableString `json:"dimensions,omitempty"`
}
// SubscriptionScopeMetricDefinitionCollection represents collection of metric definitions.
type SubscriptionScopeMetricDefinitionCollection struct {
autorest.Response `json:"-"`
// Value - The values for the metric definitions.
Value *[]SubscriptionScopeMetricDefinition `json:"value,omitempty"`
}
// SubscriptionScopeMetricResponse the response to a subscription scope metrics query.
type SubscriptionScopeMetricResponse struct {
autorest.Response `json:"-"`
// Cost - The integer value representing the relative cost of the query.
Cost *float64 `json:"cost,omitempty"`
// Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested.
Timespan *string `json:"timespan,omitempty"`
// Interval - The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made.
Interval *string `json:"interval,omitempty"`
// Namespace - The namespace of the metrics being queried
Namespace *string `json:"namespace,omitempty"`
// Resourceregion - The region of the resource being queried for metrics.
Resourceregion *string `json:"resourceregion,omitempty"`
// Value - the value of the collection.
Value *[]SubscriptionScopeMetric `json:"value,omitempty"`
}
// SubscriptionScopeMetricsRequestBodyParameters query parameters can also be specified in the body,
// specifying the same parameter in both the body and query parameters will result in an error.
type SubscriptionScopeMetricsRequestBodyParameters struct {
// Timespan - The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
Timespan *string `json:"timespan,omitempty"`
// Interval - The interval (i.e. timegrain) of the query.
Interval *string `json:"interval,omitempty"`
// MetricNames - The names of the metrics (comma separated) to retrieve.
MetricNames *string `json:"metricNames,omitempty"`
// Aggregation - The list of aggregation types (comma separated) to retrieve.
Aggregation *string `json:"aggregation,omitempty"`
// Filter - The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
Filter *string `json:"filter,omitempty"`
// Top - The maximum number of records to retrieve.
// Valid only if $filter is specified.
// Defaults to 10.
Top *int32 `json:"top,omitempty"`
// OrderBy - The aggregation to use for sorting results and the direction of the sort.
// Only one order can be specified.
// Examples: sum asc.
OrderBy *string `json:"orderBy,omitempty"`
// RollUpBy - Dimension name(s) to rollup results by. For example if you only want to see metric values with a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
RollUpBy *string `json:"rollUpBy,omitempty"`
// ResultType - Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. Possible values include: 'Data', 'Metadata'
ResultType MetricResultType `json:"resultType,omitempty"`
// MetricNamespace - Metric namespace where the metrics you want reside.
MetricNamespace *string `json:"metricNamespace,omitempty"`
// AutoAdjustTimegrain - When set to true, if the timespan passed in is not supported by this metric, the API will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan parameters. Defaults to false.
AutoAdjustTimegrain *bool `json:"autoAdjustTimegrain,omitempty"`
// ValidateDimensions - When set to false, invalid filter parameter values will be ignored. When set to true, an error is returned for invalid filter parameters. Defaults to true.
ValidateDimensions *bool `json:"validateDimensions,omitempty"`
}
// TimeSeriesBaseline the baseline values for a single time series.
type TimeSeriesBaseline struct {
// Aggregation - The aggregation type of the metric.
Aggregation *string `json:"aggregation,omitempty"`
// Dimensions - The dimensions of this time series.
Dimensions *[]SingleDimension `json:"dimensions,omitempty"`
// Timestamps - The list of timestamps of the baselines.
Timestamps *[]date.Time `json:"timestamps,omitempty"`
// Data - The baseline values for each sensitivity.
Data *[]SingleBaseline `json:"data,omitempty"`
// MetadataValues - The baseline metadata values.
MetadataValues *[]BaselineMetadata `json:"metadataValues,omitempty"`
}
// TimeSeriesElement a time series result type. The discriminator value is always TimeSeries in this case.
type TimeSeriesElement struct {
// Metadatavalues - the metadata values returned if $filter was specified in the call.
Metadatavalues *[]MetadataValue `json:"metadatavalues,omitempty"`
// Data - An array of data points representing the metric values. This is only returned if a result type of data is specified.
Data *[]Value `json:"data,omitempty"`
}
// Value represents a metric value.
type Value struct {
// TimeStamp - the timestamp for the metric value in ISO 8601 format.
TimeStamp *date.Time `json:"timeStamp,omitempty"`
// Average - the average value in the time range.
Average *float64 `json:"average,omitempty"`
// Minimum - the least value in the time range.
Minimum *float64 `json:"minimum,omitempty"`
// Maximum - the greatest value in the time range.
Maximum *float64 `json:"maximum,omitempty"`
// Total - the sum of all of the values in the time range.
Total *float64 `json:"total,omitempty"`
// Count - the number of samples in the time range. Can be used to determine the number of values that contributed to the average value.
Count *float64 `json:"count,omitempty"`
}
// WebtestLocationAvailabilityCriteria specifies the metric alert rule criteria for a web test resource.
type WebtestLocationAvailabilityCriteria struct {
// WebTestID - The Application Insights web test Id.
WebTestID *string `json:"webTestId,omitempty"`
// ComponentID - The Application Insights resource Id.
ComponentID *string `json:"componentId,omitempty"`
// FailedLocationCount - The number of failed locations.
FailedLocationCount *float64 `json:"failedLocationCount,omitempty"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
OdataType OdataType `json:"odata.type,omitempty"`
}
// MarshalJSON is the custom marshaler for WebtestLocationAvailabilityCriteria.
func (wlac WebtestLocationAvailabilityCriteria) MarshalJSON() ([]byte, error) {
wlac.OdataType = OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria
objectMap := make(map[string]interface{})
if wlac.WebTestID != nil {
objectMap["webTestId"] = wlac.WebTestID
}
if wlac.ComponentID != nil {
objectMap["componentId"] = wlac.ComponentID
}
if wlac.FailedLocationCount != nil {
objectMap["failedLocationCount"] = wlac.FailedLocationCount
}
if wlac.OdataType != "" {
objectMap["odata.type"] = wlac.OdataType
}
for k, v := range wlac.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
func (wlac WebtestLocationAvailabilityCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
func (wlac WebtestLocationAvailabilityCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
return &wlac, true
}
// AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
func (wlac WebtestLocationAvailabilityCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsAlertCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
func (wlac WebtestLocationAvailabilityCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
return nil, false
}
// AsBasicAlertCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
func (wlac WebtestLocationAvailabilityCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
return &wlac, true
}
// UnmarshalJSON is the custom unmarshaler for WebtestLocationAvailabilityCriteria struct.
func (wlac *WebtestLocationAvailabilityCriteria) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "webTestId":
if v != nil {
var webTestID string
err = json.Unmarshal(*v, &webTestID)
if err != nil {
return err
}
wlac.WebTestID = &webTestID
}
case "componentId":
if v != nil {
var componentID string
err = json.Unmarshal(*v, &componentID)
if err != nil {
return err
}
wlac.ComponentID = &componentID
}
case "failedLocationCount":
if v != nil {
var failedLocationCount float64
err = json.Unmarshal(*v, &failedLocationCount)
if err != nil {
return err
}
wlac.FailedLocationCount = &failedLocationCount
}
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if wlac.AdditionalProperties == nil {
wlac.AdditionalProperties = make(map[string]interface{})
}
wlac.AdditionalProperties[k] = additionalProperties
}
case "odata.type":
if v != nil {
var odataType OdataType
err = json.Unmarshal(*v, &odataType)
if err != nil {
return err
}
wlac.OdataType = odataType
}
}
}
return nil
}
|