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
|
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<meta name="generator" content="pdoc3 0.11.6">
<title>exchangelib.protocol API documentation</title>
<meta name="description" content="A protocol is an endpoint for EWS service connections. It contains all necessary information to make HTTPS connections …">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/13.0.0/sanitize.min.css" integrity="sha512-y1dtMcuvtTMJc1yPgEqF0ZjQbhnc/bFhyvIyVNb9Zk5mIGtqVaAB1Ttl28su8AvFMOY0EwRbAe+HCLqj6W7/KA==" crossorigin>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/13.0.0/typography.min.css" integrity="sha512-Y1DYSb995BAfxobCkKepB1BqJJTPrOp3zPL74AWFugHHmmdcvO+C48WLrUOlhGMc0QG7AE3f7gmvvcrmX2fDoA==" crossorigin>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css" crossorigin>
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:1.5em;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:2em 0 .50em 0}h3{font-size:1.4em;margin:1.6em 0 .7em 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .2s ease-in-out}a:visited{color:#503}a:hover{color:#b62}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900;font-weight:bold}pre code{font-size:.8em;line-height:1.4em;padding:1em;display:block}code{background:#f3f3f3;font-family:"DejaVu Sans Mono",monospace;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source > summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible;min-width:max-content}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em 1em;margin:1em 0}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul ul{padding-left:1em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin></script>
<script>window.addEventListener('DOMContentLoaded', () => {
hljs.configure({languages: ['bash', 'css', 'diff', 'graphql', 'ini', 'javascript', 'json', 'plaintext', 'python', 'python-repl', 'rust', 'shell', 'sql', 'typescript', 'xml', 'yaml']});
hljs.highlightAll();
/* Collapse source docstrings */
setTimeout(() => {
[...document.querySelectorAll('.hljs.language-python > .hljs-string')]
.filter(el => el.innerHTML.length > 200 && ['"""', "'''"].includes(el.innerHTML.substring(0, 3)))
.forEach(el => {
let d = document.createElement('details');
d.classList.add('hljs-string');
d.innerHTML = '<summary>"""</summary>' + el.innerHTML.substring(3);
el.replaceWith(d);
});
}, 100);
})</script>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>exchangelib.protocol</code></h1>
</header>
<section id="section-intro">
<p>A protocol is an endpoint for EWS service connections. It contains all necessary information to make HTTPS connections.</p>
<p>Protocols should be accessed through an Account, and are either created from a default Configuration or autodiscovered
when creating an Account.</p>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="exchangelib.protocol.close_connections"><code class="name flex">
<span>def <span class="ident">close_connections</span></span>(<span>)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def close_connections():
CachingProtocol.clear_cache()</code></pre>
</details>
<div class="desc"></div>
</dd>
</dl>
</section>
<section>
<h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="exchangelib.protocol.BaseProtocol"><code class="flex name class">
<span>class <span class="ident">BaseProtocol</span></span>
<span>(</span><span>config)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class BaseProtocol:
"""Base class for Protocol which implements the bare essentials."""
# The maximum number of sessions (== TCP connections, see below) we will open to this service endpoint. Keep this
# low unless you have an agreement with the Exchange admin on the receiving end to hammer the server and
# rate-limiting policies have been disabled for the connecting user. Changing this setting only makes sense if
# you are using threads to run multiple concurrent workers in this process.
SESSION_POOLSIZE = 1
# We want only 1 TCP connection per Session object. We may have lots of different credentials hitting the server and
# each credential needs its own session (NTLM auth will only send credentials once and then secure the connection,
# so a connection can only handle requests for one credential). Having multiple connections per Session could
# quickly exhaust the maximum number of concurrent connections the Exchange server allows from one client.
CONNECTIONS_PER_SESSION = 1
# The number of times a session may be reused before creating a new session object. 'None' means "infinite".
# Discarding sessions after a certain number of usages may limit memory leaks in the Session object.
MAX_SESSION_USAGE_COUNT = None
# Timeout for HTTP requests
TIMEOUT = 120
RETRY_WAIT = 10 # Seconds to wait before retry on connection errors
# The adapter class to use for HTTP requests. Override this if you need e.g. proxy support or specific TLS versions
HTTP_ADAPTER_CLS = requests.adapters.HTTPAdapter
# The User-Agent header to use for HTTP requests. Override this to set an app-specific one
USERAGENT = None
def __init__(self, config):
self.config = config
self._session_pool_size = 0
self._session_pool_maxsize = config.max_connections or self.SESSION_POOLSIZE
# Try to behave nicely with the remote server. We want to keep the connection open between requests.
# We also want to re-use sessions, to avoid the NTLM auth handshake on every request. We must know the
# authentication method to create sessions.
self._session_pool = LifoQueue()
self._session_pool_lock = Lock()
@property
def service_endpoint(self):
return self.config.service_endpoint
@abc.abstractmethod
def get_auth_type(self):
"""Autodetect authentication type"""
@property
def auth_type(self):
# Autodetect authentication type if necessary
if self.config.auth_type is None:
self.config.auth_type = self.get_auth_type()
return self.config.auth_type
@property
def credentials(self):
return self.config.credentials
@credentials.setter
def credentials(self, value):
# We are updating credentials, but that doesn't automatically propagate to the session objects. The simplest
# solution is to just kill the sessions in the pool.
with self._session_pool_lock:
self.config._credentials = value
self.close()
@property
def max_connections(self):
return self._session_pool_maxsize
@max_connections.setter
def max_connections(self, value):
with self._session_pool_lock:
self._session_pool_maxsize = value or self.SESSION_POOLSIZE
@property
def retry_policy(self):
return self.config.retry_policy
@property
def server(self):
return self.config.server
def __getstate__(self):
# The session pool and lock cannot be pickled
state = self.__dict__.copy()
del state["_session_pool"]
del state["_session_pool_lock"]
return state
def __setstate__(self, state):
# Restore the session pool and lock
self.__dict__.update(state)
self._session_pool = LifoQueue()
self._session_pool_lock = Lock()
def __del__(self):
# pylint: disable=bare-except
try:
self.close()
except Exception: # nosec
# __del__ should never fail
pass
def close(self):
log.debug("Server %s: Closing sessions", self.server)
while True:
try:
session = self._session_pool.get(block=False)
self.close_session(session)
self._session_pool_size -= 1
except Empty:
break
@classmethod
def get_adapter(cls):
# We want just one connection per session. No retries, since we wrap all requests in our own retry handler
return cls.HTTP_ADAPTER_CLS(
pool_block=True,
pool_connections=cls.CONNECTIONS_PER_SESSION,
pool_maxsize=cls.CONNECTIONS_PER_SESSION,
max_retries=0,
)
@property
def session_pool_size(self):
return self._session_pool_size
def increase_poolsize(self):
"""Increases the session pool size. We increase by one session per call."""
# Create a single session and insert it into the pool. We need to protect this with a lock while we are changing
# the pool size variable, to avoid race conditions. We must not exceed the pool size limit.
if self._session_pool_size >= self._session_pool_maxsize:
raise SessionPoolMaxSizeReached("Session pool size cannot be increased further")
with self._session_pool_lock:
if self._session_pool_size >= self._session_pool_maxsize:
log.debug("Session pool size was increased in another thread")
return
log.debug(
"Server %s: Increasing session pool size from %s to %s",
self.server,
self._session_pool_size,
self._session_pool_size + 1,
)
self._session_pool.put(self.create_session(), block=False)
self._session_pool_size += 1
def decrease_poolsize(self):
"""Decreases the session pool size in response to error messages from the server requesting to rate-limit
requests. We decrease by one session per call.
"""
# Take a single session from the pool and discard it. We need to protect this with a lock while we are changing
# the pool size variable, to avoid race conditions. We must keep at least one session in the pool.
if self._session_pool_size <= 1:
raise SessionPoolMinSizeReached("Session pool size cannot be decreased further")
with self._session_pool_lock:
if self._session_pool_size <= 1:
log.debug("Session pool size was decreased in another thread")
return
log.warning(
"Server %s: Decreasing session pool size from %s to %s",
self.server,
self._session_pool_size,
self._session_pool_size - 1,
)
session = self.get_session()
self.close_session(session)
self._session_pool_size -= 1
def get_session(self):
# Try to get a session from the queue. If the queue is empty, try to add one more session to the queue. If the
# queue is already at its max, wait until a session becomes available.
_timeout = 60 # Rate-limit messages about session starvation
try:
session = self._session_pool.get(block=False)
log.debug("Server %s: Got session immediately", self.server)
except Empty:
with suppress(SessionPoolMaxSizeReached):
self.increase_poolsize()
while True:
try:
log.debug("Server %s: Waiting for session", self.server)
session = self._session_pool.get(timeout=_timeout)
break
except Empty:
# This is normal when we have many worker threads starving for available sessions
log.debug("Server %s: No sessions available for %s seconds", self.server, _timeout)
log.debug("Server %s: Got session %s", self.server, session.session_id)
session.usage_count += 1
return session
def release_session(self, session):
# This should never fail, as we don't have more sessions than the queue contains
log.debug("Server %s: Releasing session %s", self.server, session.session_id)
if self.MAX_SESSION_USAGE_COUNT and session.usage_count >= self.MAX_SESSION_USAGE_COUNT:
log.debug("Server %s: session %s usage exceeded limit. Discarding", self.server, session.session_id)
session = self.renew_session(session)
self._session_pool.put(session, block=False)
def close_session(self, session):
if isinstance(self.credentials, BaseOAuth2Credentials) and isinstance(
self.credentials.client, BackendApplicationClient
):
# Reset access token
with self.credentials.lock:
self.credentials.access_token = None
session.close()
del session
def retire_session(self, session):
# The session is useless. Close it completely and place a fresh session in the pool
log.debug("Server %s: Retiring session %s", self.server, session.session_id)
self.close_session(session)
self.release_session(self.create_session())
def renew_session(self, session):
# The session is useless. Close it completely and place a fresh session in the pool
log.debug("Server %s: Renewing session %s", self.server, session.session_id)
self.close_session(session)
return self.create_session()
def refresh_credentials(self, session):
# Credentials need to be refreshed, probably due to an OAuth
# access token expiring. If we've gotten here, it's because the
# application didn't provide an OAuth client secret, so we can't
# handle token refreshing for it.
with self.credentials.lock:
if self.credentials.sig() == session.credentials_sig:
# Credentials have not been refreshed by another thread:
# they're the same as the session was created with. If
# this isn't the case, we can just go ahead with a new
# session using the already-updated credentials.
self.credentials.refresh(session=session)
return self.renew_session(session)
def create_session(self):
if self.credentials is None:
if self.auth_type in CREDENTIALS_REQUIRED:
raise ValueError(f"Auth type {self.auth_type!r} requires credentials")
session = self.raw_session(self.service_endpoint)
session.auth = get_auth_instance(auth_type=self.auth_type)
else:
if isinstance(self.credentials, BaseOAuth2Credentials):
with self.credentials.lock:
session = self.create_oauth2_session()
# Keep track of the credentials used to create this session. If and when we need to renew
# credentials (for example, refreshing an OAuth access token), this lets us easily determine whether
# the credentials have already been refreshed in another thread by the time this session tries.
session.credentials_sig = self.credentials.sig()
else:
if self.auth_type == NTLM and self.credentials.type == self.credentials.EMAIL:
username = "\\" + self.credentials.username
else:
username = self.credentials.username
session = self.raw_session(self.service_endpoint)
session.auth = get_auth_instance(
auth_type=self.auth_type, username=username, password=self.credentials.password
)
# Add some extra info
session.session_id = random.randint(10000, 99999) # Used for debugging messages in services
session.usage_count = 0
log.debug("Server %s: Created session %s", self.server, session.session_id)
return session
def create_oauth2_session(self):
session = self.raw_session(
self.service_endpoint,
oauth2_client=self.credentials.client,
oauth2_session_params=self.credentials.session_params(),
oauth2_token_endpoint=self.credentials.token_url,
)
if not session.token:
# Fetch the token explicitly -- it doesn't occur implicitly
token = session.fetch_token(
token_url=self.credentials.token_url,
client_id=self.credentials.client_id,
client_secret=self.credentials.client_secret,
scope=self.credentials.scope,
timeout=self.TIMEOUT,
**self.credentials.token_params(),
)
# Allow the credentials object to update its copy of the new token, and give the application an opportunity
# to cache it.
self.credentials.on_token_auto_refreshed(token)
session.auth = get_auth_instance(auth_type=OAUTH2, client=self.credentials.client)
return session
@classmethod
def raw_session(cls, prefix, oauth2_client=None, oauth2_session_params=None, oauth2_token_endpoint=None):
if oauth2_client:
session = OAuth2Session(client=oauth2_client, **(oauth2_session_params or {}))
else:
session = requests.sessions.Session()
session.headers.update(DEFAULT_HEADERS)
session.headers["User-Agent"] = cls.USERAGENT
session.mount(prefix, adapter=cls.get_adapter())
if oauth2_token_endpoint:
session.mount(oauth2_token_endpoint, adapter=cls.get_adapter())
return session
def __repr__(self):
return self.__class__.__name__ + repr((self.service_endpoint, self.credentials, self.auth_type))</code></pre>
</details>
<div class="desc"><p>Base class for Protocol which implements the bare essentials.</p></div>
<h3>Subclasses</h3>
<ul class="hlist">
<li><a title="exchangelib.autodiscover.protocol.AutodiscoverProtocol" href="autodiscover/protocol.html#exchangelib.autodiscover.protocol.AutodiscoverProtocol">AutodiscoverProtocol</a></li>
<li><a title="exchangelib.protocol.Protocol" href="#exchangelib.protocol.Protocol">Protocol</a></li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="exchangelib.protocol.BaseProtocol.CONNECTIONS_PER_SESSION"><code class="name">var <span class="ident">CONNECTIONS_PER_SESSION</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.HTTP_ADAPTER_CLS"><code class="name">var <span class="ident">HTTP_ADAPTER_CLS</span></code></dt>
<dd>
<div class="desc"><p>The built-in HTTP Adapter for urllib3.</p>
<p>Provides a general-case interface for Requests sessions to contact HTTP and
HTTPS urls by implementing the Transport Adapter interface. This class will
usually be created by the :class:<code>Session <Session></code> class under the
covers.</p>
<p>:param pool_connections: The number of urllib3 connection pools to cache.
:param pool_maxsize: The maximum number of connections to save in the pool.
:param max_retries: The maximum number of retries each connection
should attempt. Note, this applies only to failed DNS lookups, socket
connections and connection timeouts, never to requests where data has
made it to the server. By default, Requests does not retry failed
connections. If you need granular control over the conditions under
which we retry a request, import urllib3's <code>Retry</code> class and pass
that instead.
:param pool_block: Whether the connection pool should block for connections.</p>
<p>Usage::</p>
<blockquote>
<blockquote>
<blockquote>
<p>import requests
s = requests.Session()
a = requests.adapters.HTTPAdapter(max_retries=3)
s.mount('http://', a)</p>
</blockquote>
</blockquote>
</blockquote></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.MAX_SESSION_USAGE_COUNT"><code class="name">var <span class="ident">MAX_SESSION_USAGE_COUNT</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.RETRY_WAIT"><code class="name">var <span class="ident">RETRY_WAIT</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.SESSION_POOLSIZE"><code class="name">var <span class="ident">SESSION_POOLSIZE</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.TIMEOUT"><code class="name">var <span class="ident">TIMEOUT</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.USERAGENT"><code class="name">var <span class="ident">USERAGENT</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="exchangelib.protocol.BaseProtocol.get_adapter"><code class="name flex">
<span>def <span class="ident">get_adapter</span></span>(<span>)</span>
</code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.raw_session"><code class="name flex">
<span>def <span class="ident">raw_session</span></span>(<span>prefix,<br>oauth2_client=None,<br>oauth2_session_params=None,<br>oauth2_token_endpoint=None)</span>
</code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Instance variables</h3>
<dl>
<dt id="exchangelib.protocol.BaseProtocol.auth_type"><code class="name">prop <span class="ident">auth_type</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def auth_type(self):
# Autodetect authentication type if necessary
if self.config.auth_type is None:
self.config.auth_type = self.get_auth_type()
return self.config.auth_type</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.credentials"><code class="name">prop <span class="ident">credentials</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def credentials(self):
return self.config.credentials</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.max_connections"><code class="name">prop <span class="ident">max_connections</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def max_connections(self):
return self._session_pool_maxsize</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.retry_policy"><code class="name">prop <span class="ident">retry_policy</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def retry_policy(self):
return self.config.retry_policy</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.server"><code class="name">prop <span class="ident">server</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def server(self):
return self.config.server</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.service_endpoint"><code class="name">prop <span class="ident">service_endpoint</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def service_endpoint(self):
return self.config.service_endpoint</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.session_pool_size"><code class="name">prop <span class="ident">session_pool_size</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def session_pool_size(self):
return self._session_pool_size</code></pre>
</details>
<div class="desc"></div>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="exchangelib.protocol.BaseProtocol.close"><code class="name flex">
<span>def <span class="ident">close</span></span>(<span>self)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def close(self):
log.debug("Server %s: Closing sessions", self.server)
while True:
try:
session = self._session_pool.get(block=False)
self.close_session(session)
self._session_pool_size -= 1
except Empty:
break</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.close_session"><code class="name flex">
<span>def <span class="ident">close_session</span></span>(<span>self, session)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def close_session(self, session):
if isinstance(self.credentials, BaseOAuth2Credentials) and isinstance(
self.credentials.client, BackendApplicationClient
):
# Reset access token
with self.credentials.lock:
self.credentials.access_token = None
session.close()
del session</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.create_oauth2_session"><code class="name flex">
<span>def <span class="ident">create_oauth2_session</span></span>(<span>self)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def create_oauth2_session(self):
session = self.raw_session(
self.service_endpoint,
oauth2_client=self.credentials.client,
oauth2_session_params=self.credentials.session_params(),
oauth2_token_endpoint=self.credentials.token_url,
)
if not session.token:
# Fetch the token explicitly -- it doesn't occur implicitly
token = session.fetch_token(
token_url=self.credentials.token_url,
client_id=self.credentials.client_id,
client_secret=self.credentials.client_secret,
scope=self.credentials.scope,
timeout=self.TIMEOUT,
**self.credentials.token_params(),
)
# Allow the credentials object to update its copy of the new token, and give the application an opportunity
# to cache it.
self.credentials.on_token_auto_refreshed(token)
session.auth = get_auth_instance(auth_type=OAUTH2, client=self.credentials.client)
return session</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.create_session"><code class="name flex">
<span>def <span class="ident">create_session</span></span>(<span>self)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def create_session(self):
if self.credentials is None:
if self.auth_type in CREDENTIALS_REQUIRED:
raise ValueError(f"Auth type {self.auth_type!r} requires credentials")
session = self.raw_session(self.service_endpoint)
session.auth = get_auth_instance(auth_type=self.auth_type)
else:
if isinstance(self.credentials, BaseOAuth2Credentials):
with self.credentials.lock:
session = self.create_oauth2_session()
# Keep track of the credentials used to create this session. If and when we need to renew
# credentials (for example, refreshing an OAuth access token), this lets us easily determine whether
# the credentials have already been refreshed in another thread by the time this session tries.
session.credentials_sig = self.credentials.sig()
else:
if self.auth_type == NTLM and self.credentials.type == self.credentials.EMAIL:
username = "\\" + self.credentials.username
else:
username = self.credentials.username
session = self.raw_session(self.service_endpoint)
session.auth = get_auth_instance(
auth_type=self.auth_type, username=username, password=self.credentials.password
)
# Add some extra info
session.session_id = random.randint(10000, 99999) # Used for debugging messages in services
session.usage_count = 0
log.debug("Server %s: Created session %s", self.server, session.session_id)
return session</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.decrease_poolsize"><code class="name flex">
<span>def <span class="ident">decrease_poolsize</span></span>(<span>self)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def decrease_poolsize(self):
"""Decreases the session pool size in response to error messages from the server requesting to rate-limit
requests. We decrease by one session per call.
"""
# Take a single session from the pool and discard it. We need to protect this with a lock while we are changing
# the pool size variable, to avoid race conditions. We must keep at least one session in the pool.
if self._session_pool_size <= 1:
raise SessionPoolMinSizeReached("Session pool size cannot be decreased further")
with self._session_pool_lock:
if self._session_pool_size <= 1:
log.debug("Session pool size was decreased in another thread")
return
log.warning(
"Server %s: Decreasing session pool size from %s to %s",
self.server,
self._session_pool_size,
self._session_pool_size - 1,
)
session = self.get_session()
self.close_session(session)
self._session_pool_size -= 1</code></pre>
</details>
<div class="desc"><p>Decreases the session pool size in response to error messages from the server requesting to rate-limit
requests. We decrease by one session per call.</p></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.get_auth_type"><code class="name flex">
<span>def <span class="ident">get_auth_type</span></span>(<span>self)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@abc.abstractmethod
def get_auth_type(self):
"""Autodetect authentication type"""</code></pre>
</details>
<div class="desc"><p>Autodetect authentication type</p></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.get_session"><code class="name flex">
<span>def <span class="ident">get_session</span></span>(<span>self)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_session(self):
# Try to get a session from the queue. If the queue is empty, try to add one more session to the queue. If the
# queue is already at its max, wait until a session becomes available.
_timeout = 60 # Rate-limit messages about session starvation
try:
session = self._session_pool.get(block=False)
log.debug("Server %s: Got session immediately", self.server)
except Empty:
with suppress(SessionPoolMaxSizeReached):
self.increase_poolsize()
while True:
try:
log.debug("Server %s: Waiting for session", self.server)
session = self._session_pool.get(timeout=_timeout)
break
except Empty:
# This is normal when we have many worker threads starving for available sessions
log.debug("Server %s: No sessions available for %s seconds", self.server, _timeout)
log.debug("Server %s: Got session %s", self.server, session.session_id)
session.usage_count += 1
return session</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.increase_poolsize"><code class="name flex">
<span>def <span class="ident">increase_poolsize</span></span>(<span>self)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def increase_poolsize(self):
"""Increases the session pool size. We increase by one session per call."""
# Create a single session and insert it into the pool. We need to protect this with a lock while we are changing
# the pool size variable, to avoid race conditions. We must not exceed the pool size limit.
if self._session_pool_size >= self._session_pool_maxsize:
raise SessionPoolMaxSizeReached("Session pool size cannot be increased further")
with self._session_pool_lock:
if self._session_pool_size >= self._session_pool_maxsize:
log.debug("Session pool size was increased in another thread")
return
log.debug(
"Server %s: Increasing session pool size from %s to %s",
self.server,
self._session_pool_size,
self._session_pool_size + 1,
)
self._session_pool.put(self.create_session(), block=False)
self._session_pool_size += 1</code></pre>
</details>
<div class="desc"><p>Increases the session pool size. We increase by one session per call.</p></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.refresh_credentials"><code class="name flex">
<span>def <span class="ident">refresh_credentials</span></span>(<span>self, session)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def refresh_credentials(self, session):
# Credentials need to be refreshed, probably due to an OAuth
# access token expiring. If we've gotten here, it's because the
# application didn't provide an OAuth client secret, so we can't
# handle token refreshing for it.
with self.credentials.lock:
if self.credentials.sig() == session.credentials_sig:
# Credentials have not been refreshed by another thread:
# they're the same as the session was created with. If
# this isn't the case, we can just go ahead with a new
# session using the already-updated credentials.
self.credentials.refresh(session=session)
return self.renew_session(session)</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.release_session"><code class="name flex">
<span>def <span class="ident">release_session</span></span>(<span>self, session)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def release_session(self, session):
# This should never fail, as we don't have more sessions than the queue contains
log.debug("Server %s: Releasing session %s", self.server, session.session_id)
if self.MAX_SESSION_USAGE_COUNT and session.usage_count >= self.MAX_SESSION_USAGE_COUNT:
log.debug("Server %s: session %s usage exceeded limit. Discarding", self.server, session.session_id)
session = self.renew_session(session)
self._session_pool.put(session, block=False)</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.renew_session"><code class="name flex">
<span>def <span class="ident">renew_session</span></span>(<span>self, session)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def renew_session(self, session):
# The session is useless. Close it completely and place a fresh session in the pool
log.debug("Server %s: Renewing session %s", self.server, session.session_id)
self.close_session(session)
return self.create_session()</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.BaseProtocol.retire_session"><code class="name flex">
<span>def <span class="ident">retire_session</span></span>(<span>self, session)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def retire_session(self, session):
# The session is useless. Close it completely and place a fresh session in the pool
log.debug("Server %s: Retiring session %s", self.server, session.session_id)
self.close_session(session)
self.release_session(self.create_session())</code></pre>
</details>
<div class="desc"></div>
</dd>
</dl>
</dd>
<dt id="exchangelib.protocol.CachingProtocol"><code class="flex name class">
<span>class <span class="ident">CachingProtocol</span></span>
<span>(</span><span>*args, **kwargs)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class CachingProtocol(type):
"""A metaclass for Protocol that caches Protocol instances based on a server+username key."""
_protocol_cache = {}
_protocol_cache_lock = Lock()
def __call__(cls, *args, **kwargs):
# Cache Protocol instances that point to the same endpoint and use the same credentials. This ensures that we
# re-use thread and connection pools etc. instead of flooding the remote server. This is a modified Singleton
# pattern.
#
# We ignore auth_type from kwargs in the cache key. We trust caller to supply the correct auth_type - otherwise
# __init__ will guess the correct auth type.
config = kwargs["config"]
from .configuration import Configuration
if not isinstance(config, Configuration):
raise InvalidTypeError("config", config, Configuration)
if not config.service_endpoint:
raise AttributeError("'config.service_endpoint' must be set")
_protocol_cache_key = cls._cache_key(config)
try:
protocol, _ = cls._protocol_cache[_protocol_cache_key]
except KeyError:
pass
else:
if isinstance(protocol, Exception):
# The input data leads to a TransportError. Re-throw
raise protocol
return protocol
# Acquire lock to guard against multiple threads competing to cache information. Having a per-server lock is
# probably overkill, although it would reduce lock contention.
log.debug("Waiting for _protocol_cache_lock")
with cls._protocol_cache_lock:
try:
protocol, _ = cls._protocol_cache[_protocol_cache_key]
except KeyError:
pass
else:
if isinstance(protocol, Exception):
# We already tried this combination, possibly in a different competing thread, but the input
# data leads to a TransportError.
raise protocol
return protocol
log.debug("Protocol __call__ cache miss. Adding key '%s'", str(_protocol_cache_key))
try:
protocol = super().__call__(*args, **kwargs)
except TransportError as e:
# This can happen if, for example, autodiscover supplies us with a bogus EWS endpoint
log.warning("Failed to create cached protocol with key %s: %s", _protocol_cache_key, e)
cls._protocol_cache[_protocol_cache_key] = e, datetime.datetime.now()
raise e
cls._protocol_cache[_protocol_cache_key] = protocol, datetime.datetime.now()
return protocol
@staticmethod
def _cache_key(config):
# We may be using multiple different credentials for the same service endpoint. This key combination should be
# safe.
return config.service_endpoint, config.credentials
def __getitem__(cls, config):
return cls._protocol_cache[cls._cache_key(config)]
def __delitem__(cls, config):
del cls._protocol_cache[cls._cache_key(config)]
@classmethod
def clear_cache(mcs):
with mcs._protocol_cache_lock:
for key, (protocol, _) in mcs._protocol_cache.items():
if isinstance(protocol, Exception):
continue
service_endpoint = key[0]
log.debug("Service endpoint '%s': Closing sessions", service_endpoint)
with protocol._session_pool_lock:
protocol.close()
mcs._protocol_cache.clear()</code></pre>
</details>
<div class="desc"><p>A metaclass for Protocol that caches Protocol instances based on a server+username key.</p></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li>builtins.type</li>
</ul>
<h3>Static methods</h3>
<dl>
<dt id="exchangelib.protocol.CachingProtocol.clear_cache"><code class="name flex">
<span>def <span class="ident">clear_cache</span></span>(<span>)</span>
</code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
</dd>
<dt id="exchangelib.protocol.FailFast"><code class="flex name class">
<span>class <span class="ident">FailFast</span></span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class FailFast(RetryPolicy):
"""Fail immediately on server errors."""
@property
def fail_fast(self):
return True
@property
def back_off_until(self):
return None
def back_off(self, seconds):
raise ValueError("Cannot back off with fail-fast policy")</code></pre>
</details>
<div class="desc"><p>Fail immediately on server errors.</p></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="exchangelib.protocol.RetryPolicy" href="#exchangelib.protocol.RetryPolicy">RetryPolicy</a></li>
</ul>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="exchangelib.protocol.RetryPolicy" href="#exchangelib.protocol.RetryPolicy">RetryPolicy</a></b></code>:
<ul class="hlist">
<li><code><a title="exchangelib.protocol.RetryPolicy.back_off" href="#exchangelib.protocol.RetryPolicy.back_off">back_off</a></code></li>
<li><code><a title="exchangelib.protocol.RetryPolicy.back_off_until" href="#exchangelib.protocol.RetryPolicy.back_off_until">back_off_until</a></code></li>
<li><code><a title="exchangelib.protocol.RetryPolicy.fail_fast" href="#exchangelib.protocol.RetryPolicy.fail_fast">fail_fast</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="exchangelib.protocol.FaultTolerance"><code class="flex name class">
<span>class <span class="ident">FaultTolerance</span></span>
<span>(</span><span>max_wait=3600)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class FaultTolerance(RetryPolicy):
"""Enables fault-tolerant error handling. Tells internal methods to do an exponential back off when requests start
failing, and wait up to max_wait seconds before failing.
"""
# Back off 60 seconds if we didn't get an explicit suggested value
DEFAULT_BACKOFF = 60
def __init__(self, max_wait=3600):
self.max_wait = max_wait
self._back_off_until = None
self._back_off_lock = Lock()
def __getstate__(self):
# Locks cannot be pickled
state = self.__dict__.copy()
del state["_back_off_lock"]
return state
def __setstate__(self, state):
# Restore the lock
self.__dict__.update(state)
self._back_off_lock = Lock()
@property
def fail_fast(self):
return False
@property
def back_off_until(self):
"""Return the back off value as a datetime. Reset the current back off value if it has expired."""
if self._back_off_until is None:
return None
with self._back_off_lock:
if self._back_off_until is None:
return None
if self._back_off_until < datetime.datetime.now():
self._back_off_until = None # The back off value has expired. Reset
return None
return self._back_off_until
@back_off_until.setter
def back_off_until(self, value):
with self._back_off_lock:
self._back_off_until = value
def back_off(self, seconds):
if seconds is None:
seconds = self.DEFAULT_BACKOFF
if seconds > self.max_wait:
# We lost patience. Session is cleaned up in outer loop
raise RateLimitError("Max timeout reached", wait=seconds)
value = datetime.datetime.now() + datetime.timedelta(seconds=seconds)
with self._back_off_lock:
self._back_off_until = value
def raise_response_errors(self, response):
try:
return super().raise_response_errors(response)
except (ErrorInternalServerTransientError, ErrorServerBusy) as e:
# Pass on the retry header value
retry_after = _get_retry_after(response)
if retry_after:
raise ErrorServerBusy(e.args[0], back_off=retry_after)
raise</code></pre>
</details>
<div class="desc"><p>Enables fault-tolerant error handling. Tells internal methods to do an exponential back off when requests start
failing, and wait up to max_wait seconds before failing.</p></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="exchangelib.protocol.RetryPolicy" href="#exchangelib.protocol.RetryPolicy">RetryPolicy</a></li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="exchangelib.protocol.FaultTolerance.DEFAULT_BACKOFF"><code class="name">var <span class="ident">DEFAULT_BACKOFF</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
</dl>
<h3>Instance variables</h3>
<dl>
<dt id="exchangelib.protocol.FaultTolerance.back_off_until"><code class="name">prop <span class="ident">back_off_until</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def back_off_until(self):
"""Return the back off value as a datetime. Reset the current back off value if it has expired."""
if self._back_off_until is None:
return None
with self._back_off_lock:
if self._back_off_until is None:
return None
if self._back_off_until < datetime.datetime.now():
self._back_off_until = None # The back off value has expired. Reset
return None
return self._back_off_until</code></pre>
</details>
<div class="desc"><p>Return the back off value as a datetime. Reset the current back off value if it has expired.</p></div>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="exchangelib.protocol.FaultTolerance.raise_response_errors"><code class="name flex">
<span>def <span class="ident">raise_response_errors</span></span>(<span>self, response)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def raise_response_errors(self, response):
try:
return super().raise_response_errors(response)
except (ErrorInternalServerTransientError, ErrorServerBusy) as e:
# Pass on the retry header value
retry_after = _get_retry_after(response)
if retry_after:
raise ErrorServerBusy(e.args[0], back_off=retry_after)
raise</code></pre>
</details>
<div class="desc"></div>
</dd>
</dl>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="exchangelib.protocol.RetryPolicy" href="#exchangelib.protocol.RetryPolicy">RetryPolicy</a></b></code>:
<ul class="hlist">
<li><code><a title="exchangelib.protocol.RetryPolicy.back_off" href="#exchangelib.protocol.RetryPolicy.back_off">back_off</a></code></li>
<li><code><a title="exchangelib.protocol.RetryPolicy.fail_fast" href="#exchangelib.protocol.RetryPolicy.fail_fast">fail_fast</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="exchangelib.protocol.NoVerifyHTTPAdapter"><code class="flex name class">
<span>class <span class="ident">NoVerifyHTTPAdapter</span></span>
<span>(</span><span>pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class NoVerifyHTTPAdapter(requests.adapters.HTTPAdapter):
"""An HTTP adapter that ignores TLS validation errors. Use at own risk."""
def cert_verify(self, conn, url, verify, cert):
# pylint: disable=unused-argument
# We're overriding a method, so we have to keep the signature
super().cert_verify(conn=conn, url=url, verify=False, cert=cert)
def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):
# pylint: disable=unused-argument
# Required for requests >= 2.32.3
# See: https://github.com/psf/requests/pull/6710
return super().get_connection_with_tls_context(request=request, verify=False, proxies=proxies, cert=cert)</code></pre>
</details>
<div class="desc"><p>An HTTP adapter that ignores TLS validation errors. Use at own risk.</p></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li>requests.adapters.HTTPAdapter</li>
<li>requests.adapters.BaseAdapter</li>
</ul>
<h3>Methods</h3>
<dl>
<dt id="exchangelib.protocol.NoVerifyHTTPAdapter.cert_verify"><code class="name flex">
<span>def <span class="ident">cert_verify</span></span>(<span>self, conn, url, verify, cert)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def cert_verify(self, conn, url, verify, cert):
# pylint: disable=unused-argument
# We're overriding a method, so we have to keep the signature
super().cert_verify(conn=conn, url=url, verify=False, cert=cert)</code></pre>
</details>
<div class="desc"><p>Verify a SSL certificate. This method should not be called from user
code, and is only exposed for use when subclassing the
:class:<code>HTTPAdapter <requests.adapters.HTTPAdapter></code>.</p>
<p>:param conn: The urllib3 connection object associated with the cert.
:param url: The requested URL.
:param verify: Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use
:param cert: The SSL certificate to verify.</p></div>
</dd>
<dt id="exchangelib.protocol.NoVerifyHTTPAdapter.get_connection_with_tls_context"><code class="name flex">
<span>def <span class="ident">get_connection_with_tls_context</span></span>(<span>self, request, verify, proxies=None, cert=None)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):
# pylint: disable=unused-argument
# Required for requests >= 2.32.3
# See: https://github.com/psf/requests/pull/6710
return super().get_connection_with_tls_context(request=request, verify=False, proxies=proxies, cert=cert)</code></pre>
</details>
<div class="desc"><p>Returns a urllib3 connection for the given request and TLS settings.
This should not be called from user code, and is only exposed for use
when subclassing the :class:<code>HTTPAdapter <requests.adapters.HTTPAdapter></code>.</p>
<p>:param request:
The :class:<code>PreparedRequest <PreparedRequest></code> object to be sent
over the connection.
:param verify:
Either a boolean, in which case it controls whether we verify the
server's TLS certificate, or a string, in which case it must be a
path to a CA bundle to use.
:param proxies:
(optional) The proxies dictionary to apply to the request.
:param cert:
(optional) Any user-provided SSL certificate to be used for client
authentication (a.k.a., mTLS).
:rtype:
urllib3.ConnectionPool</p></div>
</dd>
</dl>
</dd>
<dt id="exchangelib.protocol.Protocol"><code class="flex name class">
<span>class <span class="ident">Protocol</span></span>
<span>(</span><span>*args, **kwargs)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class Protocol(BaseProtocol, metaclass=CachingProtocol):
"""A class to handle all the low-level communication with an Exchange server. Contains a session pool, knows how to
negotiate the authentication type of the server, refresh credentials, etc. Also contains methods for calling EWS
services that are not tied to an account.
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._version_lock = Lock()
self.api_version_hint = None
def get_auth_type(self):
# Autodetect authentication type. We also set 'self.api_version_hint' here.
return get_service_authtype(protocol=self)
@property
def version(self):
# Make sure only one thread does the guessing.
if not self.config.version or not self.config.version.build:
log.debug("Waiting for _version_lock")
with self._version_lock:
if not self.config.version or not self.config.version.build:
# Version.guess() needs auth objects and a working session pool
self.config.version = Version.guess(self, api_version_hint=self.api_version_hint)
return self.config.version
def get_timezones(self, timezones=None, return_full_timezone_data=False):
"""Get timezone definitions from the server.
:param timezones: A list of EWSDateTime instances. If None, fetches all timezones from server
(Default value = None)
:param return_full_timezone_data: If true, also returns periods and transitions (Default value = False)
:return: A generator of TimeZoneDefinition objects
"""
return GetServerTimeZones(protocol=self).call(
timezones=timezones, return_full_timezone_data=return_full_timezone_data
)
def get_free_busy_info(self, accounts, start, end, merged_free_busy_interval=30, requested_view="DetailedMerged"):
"""Return free/busy information for a list of accounts.
:param accounts: A list of (account, attendee_type, exclude_conflicts) tuples, where account is either an
Account object or a string, attendee_type is a MailboxData.attendee_type choice, and exclude_conflicts is a
boolean.
:param start: The start datetime of the request
:param end: The end datetime of the request
:param merged_free_busy_interval: The interval, in minutes, of merged free/busy information (Default value = 30)
:param requested_view: The type of information returned. Possible values are defined in the
FreeBusyViewOptions.requested_view choices. (Default value = 'DetailedMerged')
:return: A generator of FreeBusyView objects
"""
from .account import Account
tz_definition = list(self.get_timezones(timezones=[start.tzinfo], return_full_timezone_data=True))[0]
return GetUserAvailability(self).call(
tzinfo=start.tzinfo,
mailbox_data=[
MailboxData(
email=account.primary_smtp_address if isinstance(account, Account) else account,
attendee_type=attendee_type,
exclude_conflicts=exclude_conflicts,
)
for account, attendee_type, exclude_conflicts in accounts
],
timezone=TimeZone.from_server_timezone(tz_definition=tz_definition, for_year=start.year),
free_busy_view_options=FreeBusyViewOptions(
time_window=TimeWindow(start=start, end=end),
merged_free_busy_interval=merged_free_busy_interval,
requested_view=requested_view,
),
)
def get_roomlists(self):
return GetRoomLists(protocol=self).call()
def get_rooms(self, roomlist):
return GetRooms(protocol=self).call(room_list=RoomList(email_address=roomlist))
def resolve_names(self, names, parent_folders=None, return_full_contact_data=False, search_scope=None, shape=None):
"""Resolve accounts on the server using partial account data, e.g. an email address or initials.
:param names: A list of identifiers to query
:param parent_folders: A list of contact folders to search in
:param return_full_contact_data: If True, returns full contact data (Default value = False)
:param search_scope: The scope to perform the search. Must be one of SEARCH_SCOPE_CHOICES (Default value = None)
:param shape: (Default value = None)
:return: A list of Mailbox items or, if return_full_contact_data is True, tuples of (Mailbox, Contact) items
"""
return list(
ResolveNames(protocol=self).call(
unresolved_entries=names,
parent_folders=parent_folders,
return_full_contact_data=return_full_contact_data,
search_scope=search_scope,
contact_data_shape=shape,
)
)
def expand_dl(self, distribution_list):
"""Expand distribution list into its members.
:param distribution_list: SMTP address of the distribution list to expand, or a DLMailbox representing the list
:return: List of Mailbox items that are members of the distribution list
"""
if isinstance(distribution_list, str):
distribution_list = DLMailbox(email_address=distribution_list, mailbox_type="PublicDL")
return list(ExpandDL(protocol=self).call(distribution_list=distribution_list))
def get_searchable_mailboxes(self, search_filter=None, expand_group_membership=False):
"""Call the GetSearchableMailboxes service to get mailboxes that can be searched.
This method is only available to users who have been assigned the Discovery Management RBAC role. See
https://docs.microsoft.com/en-us/exchange/permissions-exo/permissions-exo
:param search_filter: If set, must be a single email alias (Default value = None)
:param expand_group_membership: If True, returned distribution lists are expanded (Default value = False)
:return: a list of SearchableMailbox, FailedMailbox or Exception instances
"""
return list(
GetSearchableMailboxes(protocol=self).call(
search_filter=search_filter,
expand_group_membership=expand_group_membership,
)
)
def convert_ids(self, ids, destination_format):
"""Convert item and folder IDs between multiple formats.
:param ids: a list of AlternateId, AlternatePublicFolderId or AlternatePublicFolderItemId instances
:param destination_format: A string
:return: a generator of AlternateId, AlternatePublicFolderId or AlternatePublicFolderItemId instances
"""
return ConvertId(protocol=self).call(items=ids, destination_format=destination_format)
def dummy_xml(self):
# Generate a minimal, valid EWS request
svc = ConvertId(protocol=self)
return svc.wrap(
content=svc.get_payload(
items=[AlternateId(id="DUMMY", format=EWS_ID, mailbox="DUMMY")],
destination_format=ENTRY_ID,
),
api_version=self.api_version_hint,
)
def __getstate__(self):
# The lock cannot be pickled
state = super().__getstate__()
del state["_version_lock"]
return state
def __setstate__(self, state):
# Restore the lock
super().__setstate__(state)
self._version_lock = Lock()
def __str__(self):
# Don't trigger version guessing here just for the sake of printing
if self.config.version:
fullname, api_version, build = self.version.fullname, self.version.api_version, self.version.build
else:
fullname, api_version, build = "[unknown]", "[unknown]", "[unknown]"
return f"""\
EWS url: {self.service_endpoint}
Product name: {fullname}
EWS API version: {api_version}
Build number: {build}
EWS auth: {self.auth_type}"""</code></pre>
</details>
<div class="desc"><p>A class to handle all the low-level communication with an Exchange server. Contains a session pool, knows how to
negotiate the authentication type of the server, refresh credentials, etc. Also contains methods for calling EWS
services that are not tied to an account.</p></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="exchangelib.protocol.BaseProtocol" href="#exchangelib.protocol.BaseProtocol">BaseProtocol</a></li>
</ul>
<h3>Instance variables</h3>
<dl>
<dt id="exchangelib.protocol.Protocol.version"><code class="name">prop <span class="ident">version</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def version(self):
# Make sure only one thread does the guessing.
if not self.config.version or not self.config.version.build:
log.debug("Waiting for _version_lock")
with self._version_lock:
if not self.config.version or not self.config.version.build:
# Version.guess() needs auth objects and a working session pool
self.config.version = Version.guess(self, api_version_hint=self.api_version_hint)
return self.config.version</code></pre>
</details>
<div class="desc"></div>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="exchangelib.protocol.Protocol.convert_ids"><code class="name flex">
<span>def <span class="ident">convert_ids</span></span>(<span>self, ids, destination_format)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def convert_ids(self, ids, destination_format):
"""Convert item and folder IDs between multiple formats.
:param ids: a list of AlternateId, AlternatePublicFolderId or AlternatePublicFolderItemId instances
:param destination_format: A string
:return: a generator of AlternateId, AlternatePublicFolderId or AlternatePublicFolderItemId instances
"""
return ConvertId(protocol=self).call(items=ids, destination_format=destination_format)</code></pre>
</details>
<div class="desc"><p>Convert item and folder IDs between multiple formats.</p>
<p>:param ids: a list of AlternateId, AlternatePublicFolderId or AlternatePublicFolderItemId instances
:param destination_format: A string</p>
<p>:return: a generator of AlternateId, AlternatePublicFolderId or AlternatePublicFolderItemId instances</p></div>
</dd>
<dt id="exchangelib.protocol.Protocol.dummy_xml"><code class="name flex">
<span>def <span class="ident">dummy_xml</span></span>(<span>self)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def dummy_xml(self):
# Generate a minimal, valid EWS request
svc = ConvertId(protocol=self)
return svc.wrap(
content=svc.get_payload(
items=[AlternateId(id="DUMMY", format=EWS_ID, mailbox="DUMMY")],
destination_format=ENTRY_ID,
),
api_version=self.api_version_hint,
)</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.Protocol.expand_dl"><code class="name flex">
<span>def <span class="ident">expand_dl</span></span>(<span>self, distribution_list)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def expand_dl(self, distribution_list):
"""Expand distribution list into its members.
:param distribution_list: SMTP address of the distribution list to expand, or a DLMailbox representing the list
:return: List of Mailbox items that are members of the distribution list
"""
if isinstance(distribution_list, str):
distribution_list = DLMailbox(email_address=distribution_list, mailbox_type="PublicDL")
return list(ExpandDL(protocol=self).call(distribution_list=distribution_list))</code></pre>
</details>
<div class="desc"><p>Expand distribution list into its members.</p>
<p>:param distribution_list: SMTP address of the distribution list to expand, or a DLMailbox representing the list</p>
<p>:return: List of Mailbox items that are members of the distribution list</p></div>
</dd>
<dt id="exchangelib.protocol.Protocol.get_free_busy_info"><code class="name flex">
<span>def <span class="ident">get_free_busy_info</span></span>(<span>self,<br>accounts,<br>start,<br>end,<br>merged_free_busy_interval=30,<br>requested_view='DetailedMerged')</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_free_busy_info(self, accounts, start, end, merged_free_busy_interval=30, requested_view="DetailedMerged"):
"""Return free/busy information for a list of accounts.
:param accounts: A list of (account, attendee_type, exclude_conflicts) tuples, where account is either an
Account object or a string, attendee_type is a MailboxData.attendee_type choice, and exclude_conflicts is a
boolean.
:param start: The start datetime of the request
:param end: The end datetime of the request
:param merged_free_busy_interval: The interval, in minutes, of merged free/busy information (Default value = 30)
:param requested_view: The type of information returned. Possible values are defined in the
FreeBusyViewOptions.requested_view choices. (Default value = 'DetailedMerged')
:return: A generator of FreeBusyView objects
"""
from .account import Account
tz_definition = list(self.get_timezones(timezones=[start.tzinfo], return_full_timezone_data=True))[0]
return GetUserAvailability(self).call(
tzinfo=start.tzinfo,
mailbox_data=[
MailboxData(
email=account.primary_smtp_address if isinstance(account, Account) else account,
attendee_type=attendee_type,
exclude_conflicts=exclude_conflicts,
)
for account, attendee_type, exclude_conflicts in accounts
],
timezone=TimeZone.from_server_timezone(tz_definition=tz_definition, for_year=start.year),
free_busy_view_options=FreeBusyViewOptions(
time_window=TimeWindow(start=start, end=end),
merged_free_busy_interval=merged_free_busy_interval,
requested_view=requested_view,
),
)</code></pre>
</details>
<div class="desc"><p>Return free/busy information for a list of accounts.</p>
<p>:param accounts: A list of (account, attendee_type, exclude_conflicts) tuples, where account is either an
Account object or a string, attendee_type is a MailboxData.attendee_type choice, and exclude_conflicts is a
boolean.
:param start: The start datetime of the request
:param end: The end datetime of the request
:param merged_free_busy_interval: The interval, in minutes, of merged free/busy information (Default value = 30)
:param requested_view: The type of information returned. Possible values are defined in the
FreeBusyViewOptions.requested_view choices. (Default value = 'DetailedMerged')</p>
<p>:return: A generator of FreeBusyView objects</p></div>
</dd>
<dt id="exchangelib.protocol.Protocol.get_roomlists"><code class="name flex">
<span>def <span class="ident">get_roomlists</span></span>(<span>self)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_roomlists(self):
return GetRoomLists(protocol=self).call()</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.Protocol.get_rooms"><code class="name flex">
<span>def <span class="ident">get_rooms</span></span>(<span>self, roomlist)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_rooms(self, roomlist):
return GetRooms(protocol=self).call(room_list=RoomList(email_address=roomlist))</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="exchangelib.protocol.Protocol.get_searchable_mailboxes"><code class="name flex">
<span>def <span class="ident">get_searchable_mailboxes</span></span>(<span>self, search_filter=None, expand_group_membership=False)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_searchable_mailboxes(self, search_filter=None, expand_group_membership=False):
"""Call the GetSearchableMailboxes service to get mailboxes that can be searched.
This method is only available to users who have been assigned the Discovery Management RBAC role. See
https://docs.microsoft.com/en-us/exchange/permissions-exo/permissions-exo
:param search_filter: If set, must be a single email alias (Default value = None)
:param expand_group_membership: If True, returned distribution lists are expanded (Default value = False)
:return: a list of SearchableMailbox, FailedMailbox or Exception instances
"""
return list(
GetSearchableMailboxes(protocol=self).call(
search_filter=search_filter,
expand_group_membership=expand_group_membership,
)
)</code></pre>
</details>
<div class="desc"><p>Call the GetSearchableMailboxes service to get mailboxes that can be searched.</p>
<p>This method is only available to users who have been assigned the Discovery Management RBAC role. See
<a href="https://docs.microsoft.com/en-us/exchange/permissions-exo/permissions-exo">https://docs.microsoft.com/en-us/exchange/permissions-exo/permissions-exo</a></p>
<p>:param search_filter: If set, must be a single email alias (Default value = None)
:param expand_group_membership: If True, returned distribution lists are expanded (Default value = False)</p>
<p>:return: a list of SearchableMailbox, FailedMailbox or Exception instances</p></div>
</dd>
<dt id="exchangelib.protocol.Protocol.get_timezones"><code class="name flex">
<span>def <span class="ident">get_timezones</span></span>(<span>self, timezones=None, return_full_timezone_data=False)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_timezones(self, timezones=None, return_full_timezone_data=False):
"""Get timezone definitions from the server.
:param timezones: A list of EWSDateTime instances. If None, fetches all timezones from server
(Default value = None)
:param return_full_timezone_data: If true, also returns periods and transitions (Default value = False)
:return: A generator of TimeZoneDefinition objects
"""
return GetServerTimeZones(protocol=self).call(
timezones=timezones, return_full_timezone_data=return_full_timezone_data
)</code></pre>
</details>
<div class="desc"><p>Get timezone definitions from the server.</p>
<p>:param timezones: A list of EWSDateTime instances. If None, fetches all timezones from server
(Default value = None)
:param return_full_timezone_data: If true, also returns periods and transitions (Default value = False)</p>
<p>:return: A generator of TimeZoneDefinition objects</p></div>
</dd>
<dt id="exchangelib.protocol.Protocol.resolve_names"><code class="name flex">
<span>def <span class="ident">resolve_names</span></span>(<span>self,<br>names,<br>parent_folders=None,<br>return_full_contact_data=False,<br>search_scope=None,<br>shape=None)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def resolve_names(self, names, parent_folders=None, return_full_contact_data=False, search_scope=None, shape=None):
"""Resolve accounts on the server using partial account data, e.g. an email address or initials.
:param names: A list of identifiers to query
:param parent_folders: A list of contact folders to search in
:param return_full_contact_data: If True, returns full contact data (Default value = False)
:param search_scope: The scope to perform the search. Must be one of SEARCH_SCOPE_CHOICES (Default value = None)
:param shape: (Default value = None)
:return: A list of Mailbox items or, if return_full_contact_data is True, tuples of (Mailbox, Contact) items
"""
return list(
ResolveNames(protocol=self).call(
unresolved_entries=names,
parent_folders=parent_folders,
return_full_contact_data=return_full_contact_data,
search_scope=search_scope,
contact_data_shape=shape,
)
)</code></pre>
</details>
<div class="desc"><p>Resolve accounts on the server using partial account data, e.g. an email address or initials.</p>
<p>:param names: A list of identifiers to query
:param parent_folders: A list of contact folders to search in
:param return_full_contact_data: If True, returns full contact data (Default value = False)
:param search_scope: The scope to perform the search. Must be one of SEARCH_SCOPE_CHOICES (Default value = None)
:param shape: (Default value = None)</p>
<p>:return: A list of Mailbox items or, if return_full_contact_data is True, tuples of (Mailbox, Contact) items</p></div>
</dd>
</dl>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="exchangelib.protocol.BaseProtocol" href="#exchangelib.protocol.BaseProtocol">BaseProtocol</a></b></code>:
<ul class="hlist">
<li><code><a title="exchangelib.protocol.BaseProtocol.CONNECTIONS_PER_SESSION" href="#exchangelib.protocol.BaseProtocol.CONNECTIONS_PER_SESSION">CONNECTIONS_PER_SESSION</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.HTTP_ADAPTER_CLS" href="#exchangelib.protocol.BaseProtocol.HTTP_ADAPTER_CLS">HTTP_ADAPTER_CLS</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.MAX_SESSION_USAGE_COUNT" href="#exchangelib.protocol.BaseProtocol.MAX_SESSION_USAGE_COUNT">MAX_SESSION_USAGE_COUNT</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.RETRY_WAIT" href="#exchangelib.protocol.BaseProtocol.RETRY_WAIT">RETRY_WAIT</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.SESSION_POOLSIZE" href="#exchangelib.protocol.BaseProtocol.SESSION_POOLSIZE">SESSION_POOLSIZE</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.TIMEOUT" href="#exchangelib.protocol.BaseProtocol.TIMEOUT">TIMEOUT</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.USERAGENT" href="#exchangelib.protocol.BaseProtocol.USERAGENT">USERAGENT</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.decrease_poolsize" href="#exchangelib.protocol.BaseProtocol.decrease_poolsize">decrease_poolsize</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.get_auth_type" href="#exchangelib.protocol.BaseProtocol.get_auth_type">get_auth_type</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.increase_poolsize" href="#exchangelib.protocol.BaseProtocol.increase_poolsize">increase_poolsize</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="exchangelib.protocol.RetryPolicy"><code class="flex name class">
<span>class <span class="ident">RetryPolicy</span></span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class RetryPolicy(metaclass=abc.ABCMeta):
"""Stores retry logic used when faced with errors from the server."""
@property
@abc.abstractmethod
def fail_fast(self):
"""Used to choose the error handling policy. When True, a fault-tolerant policy is used. False, a fail-fast
policy is used."""
@property
@abc.abstractmethod
def back_off_until(self):
"""Return a datetime to back off until"""
@back_off_until.setter
@abc.abstractmethod
def back_off_until(self, value):
"""Setter for back off values"""
@abc.abstractmethod
def back_off(self, seconds):
"""Set a new back off until value"""
def raise_response_errors(self, response):
if response.status_code == 200:
# Response is OK
return
if response.status_code == 500 and response.content and is_xml(response.content):
# Some genius at Microsoft thinks it's OK to send a valid SOAP response as an HTTP 500
log.debug("Got status code %s but trying to parse content anyway", response.status_code)
return
cas_error = response.headers.get("X-CasErrorCode")
if cas_error:
if cas_error.startswith("CAS error:"):
# Remove unnecessary text
cas_error = cas_error.split(":", 1)[1].strip()
raise CASError(cas_error=cas_error, response=response)
if response.status_code == 500 and (
b"The specified server version is invalid" in response.content
or b"ErrorInvalidSchemaVersionForMailboxVersion" in response.content
):
# Another way of communicating invalid schema versions
raise ErrorInvalidSchemaVersionForMailboxVersion("Invalid server version")
if response.headers.get("connection") == "close":
# Connection closed. OK to retry.
raise ErrorServerBusy("Caused by closed connection")
if (
response.status_code == 302
and response.headers.get("location", "").lower()
== "/ews/genericerrorpage.htm?aspxerrorpath=/ews/exchange.asmx"
):
# Redirect to genericerrorpage.htm is ridiculous behaviour for random outages. OK to retry.
#
# Redirect to '/internalsite/internalerror.asp' or '/internalsite/initparams.aspx' is caused by e.g. TLS
# certificate f*ckups on the Exchange server. We should not retry those.
raise ErrorInternalServerTransientError(f"Caused by HTTP 302 redirect to {response.headers['location']}")
if response.status_code in (301, 302):
try:
redirect_url = get_redirect_url(response=response, allow_relative=False)
except RelativeRedirect as e:
log.debug("Redirect not allowed but we were relative redirected (%s -> %s)", response.url, e.value)
raise RedirectError(url=e.value)
log.debug("Redirect not allowed but we were redirected ( (%s -> %s)", response.url, redirect_url)
raise RedirectError(url=redirect_url)
if b"The referenced account is currently locked out" in response.content:
raise UnauthorizedError("The referenced account is currently locked out")
if response.status_code == 401 and self.fail_fast:
# This is a login failure
raise UnauthorizedError(f"Invalid credentials for {response.url}")
if response.status_code == 401:
# EWS sometimes throws 401's when it wants us to throttle connections. OK to retry.
raise ErrorServerBusy("Caused by HTTP 401 response")
if response.status_code == 500 and b"Server Error in '/EWS' Application" in response.content:
# "Server Error in '/EWS' Application" has been seen in highly concurrent settings. OK to retry.
raise ErrorInternalServerTransientError("Caused by \"Server Error in 'EWS' Application\"")
if response.status_code == 503:
# Internal server error. OK to retry.
raise ErrorInternalServerTransientError("Caused by HTTP 503 response")
# This could be anything. Let higher layers handle this
raise MalformedResponseError(
f"Unknown failure in response. Code: {response.status_code} headers: {response.headers} "
f"content: {response.text}"
)</code></pre>
</details>
<div class="desc"><p>Stores retry logic used when faced with errors from the server.</p></div>
<h3>Subclasses</h3>
<ul class="hlist">
<li><a title="exchangelib.protocol.FailFast" href="#exchangelib.protocol.FailFast">FailFast</a></li>
<li><a title="exchangelib.protocol.FaultTolerance" href="#exchangelib.protocol.FaultTolerance">FaultTolerance</a></li>
</ul>
<h3>Instance variables</h3>
<dl>
<dt id="exchangelib.protocol.RetryPolicy.back_off_until"><code class="name">prop <span class="ident">back_off_until</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
@abc.abstractmethod
def back_off_until(self):
"""Return a datetime to back off until"""</code></pre>
</details>
<div class="desc"><p>Return a datetime to back off until</p></div>
</dd>
<dt id="exchangelib.protocol.RetryPolicy.fail_fast"><code class="name">prop <span class="ident">fail_fast</span></code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
@abc.abstractmethod
def fail_fast(self):
"""Used to choose the error handling policy. When True, a fault-tolerant policy is used. False, a fail-fast
policy is used."""</code></pre>
</details>
<div class="desc"><p>Used to choose the error handling policy. When True, a fault-tolerant policy is used. False, a fail-fast
policy is used.</p></div>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="exchangelib.protocol.RetryPolicy.back_off"><code class="name flex">
<span>def <span class="ident">back_off</span></span>(<span>self, seconds)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@abc.abstractmethod
def back_off(self, seconds):
"""Set a new back off until value"""</code></pre>
</details>
<div class="desc"><p>Set a new back off until value</p></div>
</dd>
<dt id="exchangelib.protocol.RetryPolicy.raise_response_errors"><code class="name flex">
<span>def <span class="ident">raise_response_errors</span></span>(<span>self, response)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def raise_response_errors(self, response):
if response.status_code == 200:
# Response is OK
return
if response.status_code == 500 and response.content and is_xml(response.content):
# Some genius at Microsoft thinks it's OK to send a valid SOAP response as an HTTP 500
log.debug("Got status code %s but trying to parse content anyway", response.status_code)
return
cas_error = response.headers.get("X-CasErrorCode")
if cas_error:
if cas_error.startswith("CAS error:"):
# Remove unnecessary text
cas_error = cas_error.split(":", 1)[1].strip()
raise CASError(cas_error=cas_error, response=response)
if response.status_code == 500 and (
b"The specified server version is invalid" in response.content
or b"ErrorInvalidSchemaVersionForMailboxVersion" in response.content
):
# Another way of communicating invalid schema versions
raise ErrorInvalidSchemaVersionForMailboxVersion("Invalid server version")
if response.headers.get("connection") == "close":
# Connection closed. OK to retry.
raise ErrorServerBusy("Caused by closed connection")
if (
response.status_code == 302
and response.headers.get("location", "").lower()
== "/ews/genericerrorpage.htm?aspxerrorpath=/ews/exchange.asmx"
):
# Redirect to genericerrorpage.htm is ridiculous behaviour for random outages. OK to retry.
#
# Redirect to '/internalsite/internalerror.asp' or '/internalsite/initparams.aspx' is caused by e.g. TLS
# certificate f*ckups on the Exchange server. We should not retry those.
raise ErrorInternalServerTransientError(f"Caused by HTTP 302 redirect to {response.headers['location']}")
if response.status_code in (301, 302):
try:
redirect_url = get_redirect_url(response=response, allow_relative=False)
except RelativeRedirect as e:
log.debug("Redirect not allowed but we were relative redirected (%s -> %s)", response.url, e.value)
raise RedirectError(url=e.value)
log.debug("Redirect not allowed but we were redirected ( (%s -> %s)", response.url, redirect_url)
raise RedirectError(url=redirect_url)
if b"The referenced account is currently locked out" in response.content:
raise UnauthorizedError("The referenced account is currently locked out")
if response.status_code == 401 and self.fail_fast:
# This is a login failure
raise UnauthorizedError(f"Invalid credentials for {response.url}")
if response.status_code == 401:
# EWS sometimes throws 401's when it wants us to throttle connections. OK to retry.
raise ErrorServerBusy("Caused by HTTP 401 response")
if response.status_code == 500 and b"Server Error in '/EWS' Application" in response.content:
# "Server Error in '/EWS' Application" has been seen in highly concurrent settings. OK to retry.
raise ErrorInternalServerTransientError("Caused by \"Server Error in 'EWS' Application\"")
if response.status_code == 503:
# Internal server error. OK to retry.
raise ErrorInternalServerTransientError("Caused by HTTP 503 response")
# This could be anything. Let higher layers handle this
raise MalformedResponseError(
f"Unknown failure in response. Code: {response.status_code} headers: {response.headers} "
f"content: {response.text}"
)</code></pre>
</details>
<div class="desc"></div>
</dd>
</dl>
</dd>
<dt id="exchangelib.protocol.TLSClientAuth"><code class="flex name class">
<span>class <span class="ident">TLSClientAuth</span></span>
<span>(</span><span>pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class TLSClientAuth(requests.adapters.HTTPAdapter):
"""An HTTP adapter that implements Certificate Based Authentication (CBA)."""
cert_file = None
def init_poolmanager(self, *args, **kwargs):
kwargs["cert_file"] = self.cert_file
return super().init_poolmanager(*args, **kwargs)</code></pre>
</details>
<div class="desc"><p>An HTTP adapter that implements Certificate Based Authentication (CBA).</p></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li>requests.adapters.HTTPAdapter</li>
<li>requests.adapters.BaseAdapter</li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="exchangelib.protocol.TLSClientAuth.cert_file"><code class="name">var <span class="ident">cert_file</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="exchangelib.protocol.TLSClientAuth.init_poolmanager"><code class="name flex">
<span>def <span class="ident">init_poolmanager</span></span>(<span>self, *args, **kwargs)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def init_poolmanager(self, *args, **kwargs):
kwargs["cert_file"] = self.cert_file
return super().init_poolmanager(*args, **kwargs)</code></pre>
</details>
<div class="desc"><p>Initializes a urllib3 PoolManager.</p>
<p>This method should not be called from user code, and is only
exposed for use when subclassing the
:class:<code>HTTPAdapter <requests.adapters.HTTPAdapter></code>.</p>
<p>:param connections: The number of urllib3 connection pools to cache.
:param maxsize: The maximum number of connections to save in the pool.
:param block: Block when no free connections are available.
:param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager.</p></div>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
<nav id="sidebar">
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="exchangelib" href="index.html">exchangelib</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="exchangelib.protocol.close_connections" href="#exchangelib.protocol.close_connections">close_connections</a></code></li>
</ul>
</li>
<li><h3><a href="#header-classes">Classes</a></h3>
<ul>
<li>
<h4><code><a title="exchangelib.protocol.BaseProtocol" href="#exchangelib.protocol.BaseProtocol">BaseProtocol</a></code></h4>
<ul class="">
<li><code><a title="exchangelib.protocol.BaseProtocol.CONNECTIONS_PER_SESSION" href="#exchangelib.protocol.BaseProtocol.CONNECTIONS_PER_SESSION">CONNECTIONS_PER_SESSION</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.HTTP_ADAPTER_CLS" href="#exchangelib.protocol.BaseProtocol.HTTP_ADAPTER_CLS">HTTP_ADAPTER_CLS</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.MAX_SESSION_USAGE_COUNT" href="#exchangelib.protocol.BaseProtocol.MAX_SESSION_USAGE_COUNT">MAX_SESSION_USAGE_COUNT</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.RETRY_WAIT" href="#exchangelib.protocol.BaseProtocol.RETRY_WAIT">RETRY_WAIT</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.SESSION_POOLSIZE" href="#exchangelib.protocol.BaseProtocol.SESSION_POOLSIZE">SESSION_POOLSIZE</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.TIMEOUT" href="#exchangelib.protocol.BaseProtocol.TIMEOUT">TIMEOUT</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.USERAGENT" href="#exchangelib.protocol.BaseProtocol.USERAGENT">USERAGENT</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.auth_type" href="#exchangelib.protocol.BaseProtocol.auth_type">auth_type</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.close" href="#exchangelib.protocol.BaseProtocol.close">close</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.close_session" href="#exchangelib.protocol.BaseProtocol.close_session">close_session</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.create_oauth2_session" href="#exchangelib.protocol.BaseProtocol.create_oauth2_session">create_oauth2_session</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.create_session" href="#exchangelib.protocol.BaseProtocol.create_session">create_session</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.credentials" href="#exchangelib.protocol.BaseProtocol.credentials">credentials</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.decrease_poolsize" href="#exchangelib.protocol.BaseProtocol.decrease_poolsize">decrease_poolsize</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.get_adapter" href="#exchangelib.protocol.BaseProtocol.get_adapter">get_adapter</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.get_auth_type" href="#exchangelib.protocol.BaseProtocol.get_auth_type">get_auth_type</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.get_session" href="#exchangelib.protocol.BaseProtocol.get_session">get_session</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.increase_poolsize" href="#exchangelib.protocol.BaseProtocol.increase_poolsize">increase_poolsize</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.max_connections" href="#exchangelib.protocol.BaseProtocol.max_connections">max_connections</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.raw_session" href="#exchangelib.protocol.BaseProtocol.raw_session">raw_session</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.refresh_credentials" href="#exchangelib.protocol.BaseProtocol.refresh_credentials">refresh_credentials</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.release_session" href="#exchangelib.protocol.BaseProtocol.release_session">release_session</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.renew_session" href="#exchangelib.protocol.BaseProtocol.renew_session">renew_session</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.retire_session" href="#exchangelib.protocol.BaseProtocol.retire_session">retire_session</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.retry_policy" href="#exchangelib.protocol.BaseProtocol.retry_policy">retry_policy</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.server" href="#exchangelib.protocol.BaseProtocol.server">server</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.service_endpoint" href="#exchangelib.protocol.BaseProtocol.service_endpoint">service_endpoint</a></code></li>
<li><code><a title="exchangelib.protocol.BaseProtocol.session_pool_size" href="#exchangelib.protocol.BaseProtocol.session_pool_size">session_pool_size</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="exchangelib.protocol.CachingProtocol" href="#exchangelib.protocol.CachingProtocol">CachingProtocol</a></code></h4>
<ul class="">
<li><code><a title="exchangelib.protocol.CachingProtocol.clear_cache" href="#exchangelib.protocol.CachingProtocol.clear_cache">clear_cache</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="exchangelib.protocol.FailFast" href="#exchangelib.protocol.FailFast">FailFast</a></code></h4>
</li>
<li>
<h4><code><a title="exchangelib.protocol.FaultTolerance" href="#exchangelib.protocol.FaultTolerance">FaultTolerance</a></code></h4>
<ul class="">
<li><code><a title="exchangelib.protocol.FaultTolerance.DEFAULT_BACKOFF" href="#exchangelib.protocol.FaultTolerance.DEFAULT_BACKOFF">DEFAULT_BACKOFF</a></code></li>
<li><code><a title="exchangelib.protocol.FaultTolerance.back_off_until" href="#exchangelib.protocol.FaultTolerance.back_off_until">back_off_until</a></code></li>
<li><code><a title="exchangelib.protocol.FaultTolerance.raise_response_errors" href="#exchangelib.protocol.FaultTolerance.raise_response_errors">raise_response_errors</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="exchangelib.protocol.NoVerifyHTTPAdapter" href="#exchangelib.protocol.NoVerifyHTTPAdapter">NoVerifyHTTPAdapter</a></code></h4>
<ul class="">
<li><code><a title="exchangelib.protocol.NoVerifyHTTPAdapter.cert_verify" href="#exchangelib.protocol.NoVerifyHTTPAdapter.cert_verify">cert_verify</a></code></li>
<li><code><a title="exchangelib.protocol.NoVerifyHTTPAdapter.get_connection_with_tls_context" href="#exchangelib.protocol.NoVerifyHTTPAdapter.get_connection_with_tls_context">get_connection_with_tls_context</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="exchangelib.protocol.Protocol" href="#exchangelib.protocol.Protocol">Protocol</a></code></h4>
<ul class="">
<li><code><a title="exchangelib.protocol.Protocol.convert_ids" href="#exchangelib.protocol.Protocol.convert_ids">convert_ids</a></code></li>
<li><code><a title="exchangelib.protocol.Protocol.dummy_xml" href="#exchangelib.protocol.Protocol.dummy_xml">dummy_xml</a></code></li>
<li><code><a title="exchangelib.protocol.Protocol.expand_dl" href="#exchangelib.protocol.Protocol.expand_dl">expand_dl</a></code></li>
<li><code><a title="exchangelib.protocol.Protocol.get_free_busy_info" href="#exchangelib.protocol.Protocol.get_free_busy_info">get_free_busy_info</a></code></li>
<li><code><a title="exchangelib.protocol.Protocol.get_roomlists" href="#exchangelib.protocol.Protocol.get_roomlists">get_roomlists</a></code></li>
<li><code><a title="exchangelib.protocol.Protocol.get_rooms" href="#exchangelib.protocol.Protocol.get_rooms">get_rooms</a></code></li>
<li><code><a title="exchangelib.protocol.Protocol.get_searchable_mailboxes" href="#exchangelib.protocol.Protocol.get_searchable_mailboxes">get_searchable_mailboxes</a></code></li>
<li><code><a title="exchangelib.protocol.Protocol.get_timezones" href="#exchangelib.protocol.Protocol.get_timezones">get_timezones</a></code></li>
<li><code><a title="exchangelib.protocol.Protocol.resolve_names" href="#exchangelib.protocol.Protocol.resolve_names">resolve_names</a></code></li>
<li><code><a title="exchangelib.protocol.Protocol.version" href="#exchangelib.protocol.Protocol.version">version</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="exchangelib.protocol.RetryPolicy" href="#exchangelib.protocol.RetryPolicy">RetryPolicy</a></code></h4>
<ul class="">
<li><code><a title="exchangelib.protocol.RetryPolicy.back_off" href="#exchangelib.protocol.RetryPolicy.back_off">back_off</a></code></li>
<li><code><a title="exchangelib.protocol.RetryPolicy.back_off_until" href="#exchangelib.protocol.RetryPolicy.back_off_until">back_off_until</a></code></li>
<li><code><a title="exchangelib.protocol.RetryPolicy.fail_fast" href="#exchangelib.protocol.RetryPolicy.fail_fast">fail_fast</a></code></li>
<li><code><a title="exchangelib.protocol.RetryPolicy.raise_response_errors" href="#exchangelib.protocol.RetryPolicy.raise_response_errors">raise_response_errors</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="exchangelib.protocol.TLSClientAuth" href="#exchangelib.protocol.TLSClientAuth">TLSClientAuth</a></code></h4>
<ul class="">
<li><code><a title="exchangelib.protocol.TLSClientAuth.cert_file" href="#exchangelib.protocol.TLSClientAuth.cert_file">cert_file</a></code></li>
<li><code><a title="exchangelib.protocol.TLSClientAuth.init_poolmanager" href="#exchangelib.protocol.TLSClientAuth.init_poolmanager">init_poolmanager</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.11.6</a>.</p>
</footer>
</body>
</html>
|