Skip to content

Commit

Permalink
Re-generate docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ecederstrand committed May 9, 2022
1 parent dfaad27 commit 95c3906
Show file tree
Hide file tree
Showing 20 changed files with 1,959 additions and 486 deletions.
29 changes: 19 additions & 10 deletions docs/exchangelib/autodiscover/discovery.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ <h1 class="title">Module <code>exchangelib.autodiscover.discovery</code></h1>

log = logging.getLogger(__name__)

DNS_LOOKUP_ERRORS = (
dns.name.EmptyLabel,
dns.resolver.NXDOMAIN,
dns.resolver.NoAnswer,
dns.resolver.NoNameservers,
)


def discover(email, credentials=None, auth_type=None, retry_policy=None):
ad_response, protocol = Autodiscovery(email=email, credentials=credentials).discover()
Expand Down Expand Up @@ -385,8 +392,9 @@ <h1 class="title">Module <code>exchangelib.autodiscover.discovery</code></h1>
def _is_valid_hostname(self, hostname):
log.debug(&#34;Checking if %s can be looked up in DNS&#34;, hostname)
try:
self.resolver.resolve(hostname)
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer, dns.name.EmptyLabel):
self.resolver.resolve(f&#34;{hostname}.&#34;, &#34;A&#34;, lifetime=self.DNS_RESOLVER_ATTRS.get(&#34;timeout&#34;))
except DNS_LOOKUP_ERRORS as e:
log.debug(&#34;DNS A lookup failure: %s&#34;, e)
return False
return True

Expand All @@ -406,9 +414,9 @@ <h1 class="title">Module <code>exchangelib.autodiscover.discovery</code></h1>
log.debug(&#34;Attempting to get SRV records for %s&#34;, hostname)
records = []
try:
answers = self.resolver.resolve(f&#34;{hostname}.&#34;, &#34;SRV&#34;)
except (dns.resolver.NoNameservers, dns.resolver.NoAnswer, dns.resolver.NXDOMAIN) as e:
log.debug(&#34;DNS lookup failure: %s&#34;, e)
answers = self.resolver.resolve(f&#34;{hostname}.&#34;, &#34;SRV&#34;, lifetime=self.DNS_RESOLVER_ATTRS.get(&#34;timeout&#34;))
except DNS_LOOKUP_ERRORS as e:
log.debug(&#34;DNS SRV lookup failure: %s&#34;, e)
return records
for rdata in answers:
try:
Expand Down Expand Up @@ -959,8 +967,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
def _is_valid_hostname(self, hostname):
log.debug(&#34;Checking if %s can be looked up in DNS&#34;, hostname)
try:
self.resolver.resolve(hostname)
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer, dns.name.EmptyLabel):
self.resolver.resolve(f&#34;{hostname}.&#34;, &#34;A&#34;, lifetime=self.DNS_RESOLVER_ATTRS.get(&#34;timeout&#34;))
except DNS_LOOKUP_ERRORS as e:
log.debug(&#34;DNS A lookup failure: %s&#34;, e)
return False
return True

Expand All @@ -980,9 +989,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
log.debug(&#34;Attempting to get SRV records for %s&#34;, hostname)
records = []
try:
answers = self.resolver.resolve(f&#34;{hostname}.&#34;, &#34;SRV&#34;)
except (dns.resolver.NoNameservers, dns.resolver.NoAnswer, dns.resolver.NXDOMAIN) as e:
log.debug(&#34;DNS lookup failure: %s&#34;, e)
answers = self.resolver.resolve(f&#34;{hostname}.&#34;, &#34;SRV&#34;, lifetime=self.DNS_RESOLVER_ATTRS.get(&#34;timeout&#34;))
except DNS_LOOKUP_ERRORS as e:
log.debug(&#34;DNS SRV lookup failure: %s&#34;, e)
return records
for rdata in answers:
try:
Expand Down
11 changes: 6 additions & 5 deletions docs/exchangelib/autodiscover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,9 @@ <h3>Inherited members</h3>
def _is_valid_hostname(self, hostname):
log.debug(&#34;Checking if %s can be looked up in DNS&#34;, hostname)
try:
self.resolver.resolve(hostname)
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer, dns.name.EmptyLabel):
self.resolver.resolve(f&#34;{hostname}.&#34;, &#34;A&#34;, lifetime=self.DNS_RESOLVER_ATTRS.get(&#34;timeout&#34;))
except DNS_LOOKUP_ERRORS as e:
log.debug(&#34;DNS A lookup failure: %s&#34;, e)
return False
return True

Expand All @@ -686,9 +687,9 @@ <h3>Inherited members</h3>
log.debug(&#34;Attempting to get SRV records for %s&#34;, hostname)
records = []
try:
answers = self.resolver.resolve(f&#34;{hostname}.&#34;, &#34;SRV&#34;)
except (dns.resolver.NoNameservers, dns.resolver.NoAnswer, dns.resolver.NXDOMAIN) as e:
log.debug(&#34;DNS lookup failure: %s&#34;, e)
answers = self.resolver.resolve(f&#34;{hostname}.&#34;, &#34;SRV&#34;, lifetime=self.DNS_RESOLVER_ATTRS.get(&#34;timeout&#34;))
except DNS_LOOKUP_ERRORS as e:
log.debug(&#34;DNS SRV lookup failure: %s&#34;, e)
return records
for rdata in answers:
try:
Expand Down
12 changes: 6 additions & 6 deletions docs/exchangelib/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ <h1 class="title">Module <code>exchangelib.configuration</code></h1>
if auth_type is None:
# Set a default auth type for the credentials where this makes sense
auth_type = DEFAULT_AUTH_TYPE.get(type(credentials))
elif credentials is None and auth_type in CREDENTIALS_REQUIRED:
if auth_type is not None and auth_type not in AUTH_TYPE_MAP:
raise InvalidEnumValue(&#34;auth_type&#34;, auth_type, AUTH_TYPE_MAP)
if credentials is None and auth_type in CREDENTIALS_REQUIRED:
raise ValueError(f&#34;Auth type {auth_type!r} was detected but no credentials were provided&#34;)
if server and service_endpoint:
raise AttributeError(&#34;Only one of &#39;server&#39; or &#39;service_endpoint&#39; must be provided&#34;)
if auth_type is not None and auth_type not in AUTH_TYPE_MAP:
raise InvalidEnumValue(&#34;auth_type&#34;, auth_type, AUTH_TYPE_MAP)
if not retry_policy:
retry_policy = FailFast()
if not isinstance(version, (Version, type(None))):
Expand Down Expand Up @@ -212,12 +212,12 @@ <h2 class="section-title" id="header-classes">Classes</h2>
if auth_type is None:
# Set a default auth type for the credentials where this makes sense
auth_type = DEFAULT_AUTH_TYPE.get(type(credentials))
elif credentials is None and auth_type in CREDENTIALS_REQUIRED:
if auth_type is not None and auth_type not in AUTH_TYPE_MAP:
raise InvalidEnumValue(&#34;auth_type&#34;, auth_type, AUTH_TYPE_MAP)
if credentials is None and auth_type in CREDENTIALS_REQUIRED:
raise ValueError(f&#34;Auth type {auth_type!r} was detected but no credentials were provided&#34;)
if server and service_endpoint:
raise AttributeError(&#34;Only one of &#39;server&#39; or &#39;service_endpoint&#39; must be provided&#34;)
if auth_type is not None and auth_type not in AUTH_TYPE_MAP:
raise InvalidEnumValue(&#34;auth_type&#34;, auth_type, AUTH_TYPE_MAP)
if not retry_policy:
retry_policy = FailFast()
if not isinstance(version, (Version, type(None))):
Expand Down
39 changes: 20 additions & 19 deletions docs/exchangelib/credentials.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,21 @@ <h1 class="title">Module <code>exchangelib.credentials</code></h1>
the associated auth code grant type for multi-tenant applications.
&#34;&#34;&#34;

def __init__(self, client_id, client_secret, tenant_id=None, identity=None):
def __init__(self, client_id, client_secret, tenant_id=None, identity=None, access_token=None):
&#34;&#34;&#34;

:param client_id: ID of an authorized OAuth application, required for automatic token fetching and refreshing
:param client_secret: Secret associated with the OAuth application
:param tenant_id: Microsoft tenant ID of the account to access
:param identity: An Identity object representing the account that these credentials are connected to.
:param access_token: Previously-obtained access token, as a dict or an oauthlib.oauth2.OAuth2Token
&#34;&#34;&#34;
super().__init__()
self.client_id = client_id
self.client_secret = client_secret
self.tenant_id = tenant_id
self.identity = identity
# When set, access_token is a dict (or an oauthlib.oauth2.OAuth2Token, which is also a dict)
self.access_token = None
self.access_token = access_token

def refresh(self, session):
# Creating a new session gets a new access token, so there&#39;s no work here to refresh the credentials. This
Expand Down Expand Up @@ -207,8 +207,8 @@ <h1 class="title">Module <code>exchangelib.credentials</code></h1>
several ways:
* Given an authorization code, client ID, and client secret, fetch a token ourselves and refresh it as needed if
supplied with a refresh token.
* Given an existing access token, refresh token, client ID, and client secret, use the access token until it
expires and then refresh it as needed.
* Given an existing access token, client ID, and client secret, use the access token until it expires and then
refresh it as needed.
* Given only an existing access token, use it until it expires. This can be used to let the calling application
refresh tokens itself by subclassing and implementing refresh().

Expand All @@ -217,7 +217,7 @@ <h1 class="title">Module <code>exchangelib.credentials</code></h1>
tenant.
&#34;&#34;&#34;

def __init__(self, authorization_code=None, access_token=None, **kwargs):
def __init__(self, authorization_code=None, access_token=None, client_id=None, client_secret=None, **kwargs):
&#34;&#34;&#34;

:param client_id: ID of an authorized OAuth application, required for automatic token fetching and refreshing
Expand All @@ -229,7 +229,7 @@ <h1 class="title">Module <code>exchangelib.credentials</code></h1>
:param access_token: Previously-obtained access token. If a token exists and the application will handle
refreshing by itself (or opts not to handle it), this parameter alone is sufficient.
&#34;&#34;&#34;
super().__init__(**kwargs)
super().__init__(client_id=client_id, client_secret=client_secret, **kwargs)
self.authorization_code = authorization_code
if access_token is not None and not isinstance(access_token, dict):
raise InvalidTypeError(&#34;access_token&#34;, access_token, OAuth2Token)
Expand Down Expand Up @@ -442,15 +442,15 @@ <h3>Inherited members</h3>
</dd>
<dt id="exchangelib.credentials.OAuth2AuthorizationCodeCredentials"><code class="flex name class">
<span>class <span class="ident">OAuth2AuthorizationCodeCredentials</span></span>
<span>(</span><span>authorization_code=None, access_token=None, **kwargs)</span>
<span>(</span><span>authorization_code=None, access_token=None, client_id=None, client_secret=None, **kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>Login info for OAuth 2.0 authentication using the authorization code grant type. This can be used in one of
several ways:
* Given an authorization code, client ID, and client secret, fetch a token ourselves and refresh it as needed if
supplied with a refresh token.
* Given an existing access token, refresh token, client ID, and client secret, use the access token until it
expires and then refresh it as needed.
* Given an existing access token, client ID, and client secret, use the access token until it expires and then
refresh it as needed.
* Given only an existing access token, use it until it expires. This can be used to let the calling application
refresh tokens itself by subclassing and implementing refresh().</p>
<p>Unlike the base (client credentials) grant, authorization code credentials don't require a Microsoft tenant ID
Expand All @@ -473,8 +473,8 @@ <h3>Inherited members</h3>
several ways:
* Given an authorization code, client ID, and client secret, fetch a token ourselves and refresh it as needed if
supplied with a refresh token.
* Given an existing access token, refresh token, client ID, and client secret, use the access token until it
expires and then refresh it as needed.
* Given an existing access token, client ID, and client secret, use the access token until it expires and then
refresh it as needed.
* Given only an existing access token, use it until it expires. This can be used to let the calling application
refresh tokens itself by subclassing and implementing refresh().

Expand All @@ -483,7 +483,7 @@ <h3>Inherited members</h3>
tenant.
&#34;&#34;&#34;

def __init__(self, authorization_code=None, access_token=None, **kwargs):
def __init__(self, authorization_code=None, access_token=None, client_id=None, client_secret=None, **kwargs):
&#34;&#34;&#34;

:param client_id: ID of an authorized OAuth application, required for automatic token fetching and refreshing
Expand All @@ -495,7 +495,7 @@ <h3>Inherited members</h3>
:param access_token: Previously-obtained access token. If a token exists and the application will handle
refreshing by itself (or opts not to handle it), this parameter alone is sufficient.
&#34;&#34;&#34;
super().__init__(**kwargs)
super().__init__(client_id=client_id, client_secret=client_secret, **kwargs)
self.authorization_code = authorization_code
if access_token is not None and not isinstance(access_token, dict):
raise InvalidTypeError(&#34;access_token&#34;, access_token, OAuth2Token)
Expand Down Expand Up @@ -533,7 +533,7 @@ <h3>Inherited members</h3>
</dd>
<dt id="exchangelib.credentials.OAuth2Credentials"><code class="flex name class">
<span>class <span class="ident">OAuth2Credentials</span></span>
<span>(</span><span>client_id, client_secret, tenant_id=None, identity=None)</span>
<span>(</span><span>client_id, client_secret, tenant_id=None, identity=None, access_token=None)</span>
</code></dt>
<dd>
<div class="desc"><p>Login info for OAuth 2.0 client credentials authentication, as well as a base for other OAuth 2.0 grant types.</p>
Expand All @@ -544,7 +544,8 @@ <h3>Inherited members</h3>
<p>:param client_id: ID of an authorized OAuth application, required for automatic token fetching and refreshing
:param client_secret: Secret associated with the OAuth application
:param tenant_id: Microsoft tenant ID of the account to access
:param identity: An Identity object representing the account that these credentials are connected to.</p></div>
:param identity: An Identity object representing the account that these credentials are connected to.
:param access_token: Previously-obtained access token, as a dict or an oauthlib.oauth2.OAuth2Token</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
Expand All @@ -558,21 +559,21 @@ <h3>Inherited members</h3>
the associated auth code grant type for multi-tenant applications.
&#34;&#34;&#34;

def __init__(self, client_id, client_secret, tenant_id=None, identity=None):
def __init__(self, client_id, client_secret, tenant_id=None, identity=None, access_token=None):
&#34;&#34;&#34;

:param client_id: ID of an authorized OAuth application, required for automatic token fetching and refreshing
:param client_secret: Secret associated with the OAuth application
:param tenant_id: Microsoft tenant ID of the account to access
:param identity: An Identity object representing the account that these credentials are connected to.
:param access_token: Previously-obtained access token, as a dict or an oauthlib.oauth2.OAuth2Token
&#34;&#34;&#34;
super().__init__()
self.client_id = client_id
self.client_secret = client_secret
self.tenant_id = tenant_id
self.identity = identity
# When set, access_token is a dict (or an oauthlib.oauth2.OAuth2Token, which is also a dict)
self.access_token = None
self.access_token = access_token

def refresh(self, session):
# Creating a new session gets a new access token, so there&#39;s no work here to refresh the credentials. This
Expand Down
Loading

0 comments on commit 95c3906

Please sign in to comment.