Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 🚀 Add InboxRule implement #1272

Merged
merged 16 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
565 changes: 562 additions & 3 deletions docs/exchangelib/account.html

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions docs/exchangelib/autodiscover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ <h3>Methods</h3>
&#34;external_ews_url&#34;,
&#34;ews_supported_schemas&#34;,
]
for setting in settings:
if setting not in UserResponse.SETTINGS_MAP:
raise ValueError(
f&#34;Setting {setting!r} is invalid. Valid options are: {sorted(UserResponse.SETTINGS_MAP.keys())}&#34;
)
return GetUserSettings(protocol=self).get(users=[user], settings=settings)

def dummy_xml(self):
Expand Down Expand Up @@ -424,6 +429,11 @@ <h3>Methods</h3>
&#34;external_ews_url&#34;,
&#34;ews_supported_schemas&#34;,
]
for setting in settings:
if setting not in UserResponse.SETTINGS_MAP:
raise ValueError(
f&#34;Setting {setting!r} is invalid. Valid options are: {sorted(UserResponse.SETTINGS_MAP.keys())}&#34;
)
return GetUserSettings(protocol=self).get(users=[user], settings=settings)</code></pre>
</details>
</dd>
Expand Down
18 changes: 17 additions & 1 deletion docs/exchangelib/autodiscover/protocol.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ <h1 class="title">Module <code>exchangelib.autodiscover.protocol</code></h1>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from ..protocol import BaseProtocol
<pre><code class="python">from ..properties import UserResponse
from ..protocol import BaseProtocol
from ..services import GetUserSettings
from ..transport import get_autodiscover_authtype
from ..version import Version
Expand Down Expand Up @@ -73,6 +74,11 @@ <h1 class="title">Module <code>exchangelib.autodiscover.protocol</code></h1>
&#34;external_ews_url&#34;,
&#34;ews_supported_schemas&#34;,
]
for setting in settings:
if setting not in UserResponse.SETTINGS_MAP:
raise ValueError(
f&#34;Setting {setting!r} is invalid. Valid options are: {sorted(UserResponse.SETTINGS_MAP.keys())}&#34;
)
return GetUserSettings(protocol=self).get(users=[user], settings=settings)

def dummy_xml(self):
Expand Down Expand Up @@ -147,6 +153,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>
&#34;external_ews_url&#34;,
&#34;ews_supported_schemas&#34;,
]
for setting in settings:
if setting not in UserResponse.SETTINGS_MAP:
raise ValueError(
f&#34;Setting {setting!r} is invalid. Valid options are: {sorted(UserResponse.SETTINGS_MAP.keys())}&#34;
)
return GetUserSettings(protocol=self).get(users=[user], settings=settings)

def dummy_xml(self):
Expand Down Expand Up @@ -243,6 +254,11 @@ <h3>Methods</h3>
&#34;external_ews_url&#34;,
&#34;ews_supported_schemas&#34;,
]
for setting in settings:
if setting not in UserResponse.SETTINGS_MAP:
raise ValueError(
f&#34;Setting {setting!r} is invalid. Valid options are: {sorted(UserResponse.SETTINGS_MAP.keys())}&#34;
)
return GetUserSettings(protocol=self).get(users=[user], settings=settings)</code></pre>
</details>
</dd>
Expand Down
2 changes: 1 addition & 1 deletion docs/exchangelib/ewsdatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ <h3>Static methods</h3>
<span>def <span class="ident">fromisoformat</span></span>(<span>date_string)</span>
</code></dt>
<dd>
<div class="desc"><p>string -&gt; datetime from datetime.isoformat() output</p></div>
<div class="desc"><p>string -&gt; datetime from a string in most ISO 8601 formats</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
Expand Down
234 changes: 217 additions & 17 deletions docs/exchangelib/fields.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ <h1 class="title">Module <code>exchangelib.fields</code></h1>
<pre><code class="python">import abc
import datetime
import logging
import warnings
from contextlib import suppress
from decimal import Decimal, InvalidOperation
from importlib import import_module
Expand Down Expand Up @@ -767,16 +768,21 @@ <h1 class="title">Module <code>exchangelib.fields</code></h1>
def from_xml(self, elem, account):
field_elem = elem.find(self.response_tag())
if field_elem is not None:
ms_id = field_elem.get(&#34;Id&#34;)
ms_name = field_elem.get(&#34;Name&#34;)
tz_id = field_elem.get(&#34;Id&#34;) or field_elem.get(&#34;Name&#34;)
try:
return self.value_cls.from_ms_id(ms_id or ms_name)
return self.value_cls.from_ms_id(tz_id)
except UnknownTimeZone:
log.warning(
&#34;Cannot convert value &#39;%s&#39; on field &#39;%s&#39; to type %s (unknown timezone ID)&#34;,
(ms_id or ms_name),
self.name,
self.value_cls,
warnings.warn(
f&#34;&#34;&#34;\
Cannot convert value {tz_id!r} on field {self.name!r} to type {self.value_cls.__name__!r} (unknown timezone ID).
You can fix this by adding a custom entry into the timezone translation map:

from exchangelib.winzone import MS_TIMEZONE_TO_IANA_MAP, CLDR_TO_MS_TIMEZONE_MAP

# Replace &#34;Some_Region/Some_Location&#34; with a reasonable value from CLDR_TO_MS_TIMEZONE_MAP.keys()
MS_TIMEZONE_TO_IANA_MAP[{tz_id!r}] = &#34;Some_Region/Some_Location&#34;

# Your code here&#34;&#34;&#34;
)
return None
return self.default
Expand Down Expand Up @@ -1744,7 +1750,65 @@ <h1 class="title">Module <code>exchangelib.fields</code></h1>
except KeyError:
continue
events.append(value_cls.from_xml(elem=event, account=account))
return events or self.default</code></pre>
return events or self.default


FLAG_ACTION_CHOICES = [
Choice(&#34;Any&#34;),
Choice(&#34;Call&#34;),
Choice(&#34;DoNotForward&#34;),
Choice(&#34;FollowUp&#34;),
Choice(&#34;FYI&#34;),
Choice(&#34;Forward&#34;),
Choice(&#34;NoResponseNecessary&#34;),
Choice(&#34;Read&#34;),
Choice(&#34;Reply&#34;),
Choice(&#34;ReplyToAll&#34;),
Choice(&#34;Review&#34;),
]


class FlaggedForActionField(ChoiceField):
&#34;&#34;&#34;A field specifies the flag for action value that
must appear on incoming messages in order for the condition
or exception to apply.&#34;&#34;&#34;

def __init__(self, *args, **kwargs):
kwargs[&#34;choices&#34;] = FLAG_ACTION_CHOICES
super().__init__(*args, **kwargs)


IMPORTANCE_CHOICES = [
Choice(&#34;Low&#34;),
Choice(&#34;Normal&#34;),
Choice(&#34;High&#34;),
]


class ImportanceField(ChoiceField):
&#34;&#34;&#34;A field that describes the importance of an item or
the aggregated importance of all items in a conversation
in the current folder.&#34;&#34;&#34;

def __init__(self, *args, **kwargs):
kwargs[&#34;choices&#34;] = IMPORTANCE_CHOICES
super().__init__(*args, **kwargs)


SENSITIVITY_CHOICES = [
Choice(&#34;Normal&#34;),
Choice(&#34;Personal&#34;),
Choice(&#34;Private&#34;),
Choice(&#34;Confidential&#34;),
]


class SensitivityField(ChoiceField):
&#34;&#34;&#34;A field that indicates the sensitivity level of an item.&#34;&#34;&#34;

def __init__(self, *args, **kwargs):
kwargs[&#34;choices&#34;] = SENSITIVITY_CHOICES
super().__init__(*args, **kwargs)</code></pre>
</details>
</section>
<section>
Expand Down Expand Up @@ -2628,9 +2692,12 @@ <h3>Ancestors</h3>
</ul>
<h3>Subclasses</h3>
<ul class="hlist">
<li><a title="exchangelib.fields.FlaggedForActionField" href="#exchangelib.fields.FlaggedForActionField">FlaggedForActionField</a></li>
<li><a title="exchangelib.fields.FreeBusyStatusField" href="#exchangelib.fields.FreeBusyStatusField">FreeBusyStatusField</a></li>
<li><a title="exchangelib.fields.ImportanceField" href="#exchangelib.fields.ImportanceField">ImportanceField</a></li>
<li><a title="exchangelib.fields.LabelField" href="#exchangelib.fields.LabelField">LabelField</a></li>
<li><a title="exchangelib.fields.RoutingTypeField" href="#exchangelib.fields.RoutingTypeField">RoutingTypeField</a></li>
<li><a title="exchangelib.fields.SensitivityField" href="#exchangelib.fields.SensitivityField">SensitivityField</a></li>
</ul>
<h3>Methods</h3>
<dl>
Expand Down Expand Up @@ -4637,6 +4704,47 @@ <h3>Inherited members</h3>
</li>
</ul>
</dd>
<dt id="exchangelib.fields.FlaggedForActionField"><code class="flex name class">
<span>class <span class="ident">FlaggedForActionField</span></span>
<span>(</span><span>*args, **kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>A field specifies the flag for action value that
must appear on incoming messages in order for the condition
or exception to apply.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class FlaggedForActionField(ChoiceField):
&#34;&#34;&#34;A field specifies the flag for action value that
must appear on incoming messages in order for the condition
or exception to apply.&#34;&#34;&#34;

def __init__(self, *args, **kwargs):
kwargs[&#34;choices&#34;] = FLAG_ACTION_CHOICES
super().__init__(*args, **kwargs)</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="exchangelib.fields.ChoiceField" href="#exchangelib.fields.ChoiceField">ChoiceField</a></li>
<li><a title="exchangelib.fields.CharField" href="#exchangelib.fields.CharField">CharField</a></li>
<li><a title="exchangelib.fields.TextField" href="#exchangelib.fields.TextField">TextField</a></li>
<li><a title="exchangelib.fields.FieldURIField" href="#exchangelib.fields.FieldURIField">FieldURIField</a></li>
<li><a title="exchangelib.fields.Field" href="#exchangelib.fields.Field">Field</a></li>
<li><a title="exchangelib.version.SupportedVersionInstanceMixIn" href="version.html#exchangelib.version.SupportedVersionInstanceMixIn">SupportedVersionInstanceMixIn</a></li>
</ul>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="exchangelib.fields.ChoiceField" href="#exchangelib.fields.ChoiceField">ChoiceField</a></b></code>:
<ul class="hlist">
<li><code><a title="exchangelib.fields.ChoiceField.from_xml" href="#exchangelib.fields.Field.from_xml">from_xml</a></code></li>
<li><code><a title="exchangelib.fields.ChoiceField.to_xml" href="#exchangelib.fields.Field.to_xml">to_xml</a></code></li>
<li><code><a title="exchangelib.fields.ChoiceField.value_cls" href="#exchangelib.fields.TextField.value_cls">value_cls</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="exchangelib.fields.FreeBusyStatusField"><code class="flex name class">
<span>class <span class="ident">FreeBusyStatusField</span></span>
<span>(</span><span>*args, **kwargs)</span>
Expand Down Expand Up @@ -4830,6 +4938,47 @@ <h3>Inherited members</h3>
</li>
</ul>
</dd>
<dt id="exchangelib.fields.ImportanceField"><code class="flex name class">
<span>class <span class="ident">ImportanceField</span></span>
<span>(</span><span>*args, **kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>A field that describes the importance of an item or
the aggregated importance of all items in a conversation
in the current folder.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class ImportanceField(ChoiceField):
&#34;&#34;&#34;A field that describes the importance of an item or
the aggregated importance of all items in a conversation
in the current folder.&#34;&#34;&#34;

def __init__(self, *args, **kwargs):
kwargs[&#34;choices&#34;] = IMPORTANCE_CHOICES
super().__init__(*args, **kwargs)</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="exchangelib.fields.ChoiceField" href="#exchangelib.fields.ChoiceField">ChoiceField</a></li>
<li><a title="exchangelib.fields.CharField" href="#exchangelib.fields.CharField">CharField</a></li>
<li><a title="exchangelib.fields.TextField" href="#exchangelib.fields.TextField">TextField</a></li>
<li><a title="exchangelib.fields.FieldURIField" href="#exchangelib.fields.FieldURIField">FieldURIField</a></li>
<li><a title="exchangelib.fields.Field" href="#exchangelib.fields.Field">Field</a></li>
<li><a title="exchangelib.version.SupportedVersionInstanceMixIn" href="version.html#exchangelib.version.SupportedVersionInstanceMixIn">SupportedVersionInstanceMixIn</a></li>
</ul>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="exchangelib.fields.ChoiceField" href="#exchangelib.fields.ChoiceField">ChoiceField</a></b></code>:
<ul class="hlist">
<li><code><a title="exchangelib.fields.ChoiceField.from_xml" href="#exchangelib.fields.Field.from_xml">from_xml</a></code></li>
<li><code><a title="exchangelib.fields.ChoiceField.to_xml" href="#exchangelib.fields.Field.to_xml">to_xml</a></code></li>
<li><code><a title="exchangelib.fields.ChoiceField.value_cls" href="#exchangelib.fields.TextField.value_cls">value_cls</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="exchangelib.fields.IndexedField"><code class="flex name class">
<span>class <span class="ident">IndexedField</span></span>
<span>(</span><span>*args, **kwargs)</span>
Expand Down Expand Up @@ -6074,6 +6223,43 @@ <h3>Inherited members</h3>
</li>
</ul>
</dd>
<dt id="exchangelib.fields.SensitivityField"><code class="flex name class">
<span>class <span class="ident">SensitivityField</span></span>
<span>(</span><span>*args, **kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>A field that indicates the sensitivity level of an item.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class SensitivityField(ChoiceField):
&#34;&#34;&#34;A field that indicates the sensitivity level of an item.&#34;&#34;&#34;

def __init__(self, *args, **kwargs):
kwargs[&#34;choices&#34;] = SENSITIVITY_CHOICES
super().__init__(*args, **kwargs)</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="exchangelib.fields.ChoiceField" href="#exchangelib.fields.ChoiceField">ChoiceField</a></li>
<li><a title="exchangelib.fields.CharField" href="#exchangelib.fields.CharField">CharField</a></li>
<li><a title="exchangelib.fields.TextField" href="#exchangelib.fields.TextField">TextField</a></li>
<li><a title="exchangelib.fields.FieldURIField" href="#exchangelib.fields.FieldURIField">FieldURIField</a></li>
<li><a title="exchangelib.fields.Field" href="#exchangelib.fields.Field">Field</a></li>
<li><a title="exchangelib.version.SupportedVersionInstanceMixIn" href="version.html#exchangelib.version.SupportedVersionInstanceMixIn">SupportedVersionInstanceMixIn</a></li>
</ul>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="exchangelib.fields.ChoiceField" href="#exchangelib.fields.ChoiceField">ChoiceField</a></b></code>:
<ul class="hlist">
<li><code><a title="exchangelib.fields.ChoiceField.from_xml" href="#exchangelib.fields.Field.from_xml">from_xml</a></code></li>
<li><code><a title="exchangelib.fields.ChoiceField.to_xml" href="#exchangelib.fields.Field.to_xml">to_xml</a></code></li>
<li><code><a title="exchangelib.fields.ChoiceField.value_cls" href="#exchangelib.fields.TextField.value_cls">value_cls</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="exchangelib.fields.StringAttributedValueField"><code class="flex name class">
<span>class <span class="ident">StringAttributedValueField</span></span>
<span>(</span><span>*args, **kwargs)</span>
Expand Down Expand Up @@ -6571,16 +6757,21 @@ <h3>Inherited members</h3>
def from_xml(self, elem, account):
field_elem = elem.find(self.response_tag())
if field_elem is not None:
ms_id = field_elem.get(&#34;Id&#34;)
ms_name = field_elem.get(&#34;Name&#34;)
tz_id = field_elem.get(&#34;Id&#34;) or field_elem.get(&#34;Name&#34;)
try:
return self.value_cls.from_ms_id(ms_id or ms_name)
return self.value_cls.from_ms_id(tz_id)
except UnknownTimeZone:
log.warning(
&#34;Cannot convert value &#39;%s&#39; on field &#39;%s&#39; to type %s (unknown timezone ID)&#34;,
(ms_id or ms_name),
self.name,
self.value_cls,
warnings.warn(
f&#34;&#34;&#34;\
Cannot convert value {tz_id!r} on field {self.name!r} to type {self.value_cls.__name__!r} (unknown timezone ID).
You can fix this by adding a custom entry into the timezone translation map:

from exchangelib.winzone import MS_TIMEZONE_TO_IANA_MAP, CLDR_TO_MS_TIMEZONE_MAP

# Replace &#34;Some_Region/Some_Location&#34; with a reasonable value from CLDR_TO_MS_TIMEZONE_MAP.keys()
MS_TIMEZONE_TO_IANA_MAP[{tz_id!r}] = &#34;Some_Region/Some_Location&#34;

# Your code here&#34;&#34;&#34;
)
return None
return self.default
Expand Down Expand Up @@ -7247,6 +7438,9 @@ <h4><code><a title="exchangelib.fields.FieldURIField" href="#exchangelib.fields.
</ul>
</li>
<li>
<h4><code><a title="exchangelib.fields.FlaggedForActionField" href="#exchangelib.fields.FlaggedForActionField">FlaggedForActionField</a></code></h4>
</li>
<li>
<h4><code><a title="exchangelib.fields.FreeBusyStatusField" href="#exchangelib.fields.FreeBusyStatusField">FreeBusyStatusField</a></code></h4>
</li>
<li>
Expand All @@ -7262,6 +7456,9 @@ <h4><code><a title="exchangelib.fields.IdElementField" href="#exchangelib.fields
<h4><code><a title="exchangelib.fields.IdField" href="#exchangelib.fields.IdField">IdField</a></code></h4>
</li>
<li>
<h4><code><a title="exchangelib.fields.ImportanceField" href="#exchangelib.fields.ImportanceField">ImportanceField</a></code></h4>
</li>
<li>
<h4><code><a title="exchangelib.fields.IndexedField" href="#exchangelib.fields.IndexedField">IndexedField</a></code></h4>
<ul class="">
<li><code><a title="exchangelib.fields.IndexedField.PARENT_ELEMENT_NAME" href="#exchangelib.fields.IndexedField.PARENT_ELEMENT_NAME">PARENT_ELEMENT_NAME</a></code></li>
Expand Down Expand Up @@ -7393,6 +7590,9 @@ <h4><code><a title="exchangelib.fields.ReferenceItemIdField" href="#exchangelib.
<h4><code><a title="exchangelib.fields.RoutingTypeField" href="#exchangelib.fields.RoutingTypeField">RoutingTypeField</a></code></h4>
</li>
<li>
<h4><code><a title="exchangelib.fields.SensitivityField" href="#exchangelib.fields.SensitivityField">SensitivityField</a></code></h4>
</li>
<li>
<h4><code><a title="exchangelib.fields.StringAttributedValueField" href="#exchangelib.fields.StringAttributedValueField">StringAttributedValueField</a></code></h4>
</li>
<li>
Expand Down
Loading