Skip to content

Commit

Permalink
version 1.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed May 18, 2022
1 parent 0a2cee6 commit 647701e
Show file tree
Hide file tree
Showing 49 changed files with 19,294 additions and 127 deletions.
8 changes: 7 additions & 1 deletion docs/api-docs/slack_bolt/adapter/aiohttp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ <h1 class="title">Module <code>slack_bolt.adapter.aiohttp</code></h1>
secure=True,
httponly=True,
)
return resp</code></pre>
return resp


__all__ = [
&#34;to_bolt_request&#34;,
&#34;to_aiohttp_response&#34;,
]</code></pre>
</details>
</section>
<section>
Expand Down
171 changes: 170 additions & 1 deletion docs/api-docs/slack_bolt/adapter/aws_lambda/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ <h1 class="title">Module <code>slack_bolt.adapter.aws_lambda</code></h1>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from .handler import SlackRequestHandler # noqa: F401</code></pre>
<pre><code class="python">from .handler import SlackRequestHandler

__all__ = [
&#34;SlackRequestHandler&#34;,
]</code></pre>
</details>
</section>
<section>
Expand Down Expand Up @@ -67,6 +71,160 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
<section>
</section>
<section>
<h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="slack_bolt.adapter.aws_lambda.SlackRequestHandler"><code class="flex name class">
<span>class <span class="ident">SlackRequestHandler</span></span>
<span>(</span><span>app: <a title="slack_bolt.app.app.App" href="../../app/app.html#slack_bolt.app.app.App">App</a>)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class SlackRequestHandler:
def __init__(self, app: App): # type: ignore
self.app = app
self.logger = get_bolt_app_logger(app.name, SlackRequestHandler, app.logger)
self.app.listener_runner.lazy_listener_runner = LambdaLazyListenerRunner(
self.logger
)
if self.app.oauth_flow is not None:
self.app.oauth_flow.settings.redirect_uri_page_renderer.install_path = &#34;?&#34;

@classmethod
def clear_all_log_handlers(cls):
# https://stackoverflow.com/questions/37703609/using-python-logging-with-aws-lambda
root = logging.getLogger()
if root.handlers:
for handler in root.handlers:
root.removeHandler(handler)

def handle(self, event, context):
self.logger.debug(f&#34;Incoming event: {event}, context: {context}&#34;)

method = event.get(&#34;requestContext&#34;, {}).get(&#34;http&#34;, {}).get(&#34;method&#34;)
if method is None:
method = event.get(&#34;requestContext&#34;, {}).get(&#34;httpMethod&#34;)

if method is None:
return not_found()
if method == &#34;GET&#34;:
if self.app.oauth_flow is not None:
oauth_flow: OAuthFlow = self.app.oauth_flow
bolt_req: BoltRequest = to_bolt_request(event)
query = bolt_req.query
is_callback = query is not None and (
(
_first_value(query, &#34;code&#34;) is not None
and _first_value(query, &#34;state&#34;) is not None
)
or _first_value(query, &#34;error&#34;) is not None
)
if is_callback:
bolt_resp = oauth_flow.handle_callback(bolt_req)
return to_aws_response(bolt_resp)
else:
bolt_resp = oauth_flow.handle_installation(bolt_req)
return to_aws_response(bolt_resp)
elif method == &#34;POST&#34;:
bolt_req = to_bolt_request(event)
# https://docs.aws.amazon.com/lambda/latest/dg/python-context.html
aws_lambda_function_name = context.function_name
bolt_req.context[&#34;aws_lambda_function_name&#34;] = aws_lambda_function_name
bolt_req.context[&#34;lambda_request&#34;] = event
bolt_resp = self.app.dispatch(bolt_req)
aws_response = to_aws_response(bolt_resp)
return aws_response
elif method == &#34;NONE&#34;:
bolt_req = to_bolt_request(event)
bolt_resp = self.app.dispatch(bolt_req)
aws_response = to_aws_response(bolt_resp)
return aws_response

return not_found()</code></pre>
</details>
<h3>Static methods</h3>
<dl>
<dt id="slack_bolt.adapter.aws_lambda.SlackRequestHandler.clear_all_log_handlers"><code class="name flex">
<span>def <span class="ident">clear_all_log_handlers</span></span>(<span>)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def clear_all_log_handlers(cls):
# https://stackoverflow.com/questions/37703609/using-python-logging-with-aws-lambda
root = logging.getLogger()
if root.handlers:
for handler in root.handlers:
root.removeHandler(handler)</code></pre>
</details>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="slack_bolt.adapter.aws_lambda.SlackRequestHandler.handle"><code class="name flex">
<span>def <span class="ident">handle</span></span>(<span>self, event, context)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def handle(self, event, context):
self.logger.debug(f&#34;Incoming event: {event}, context: {context}&#34;)

method = event.get(&#34;requestContext&#34;, {}).get(&#34;http&#34;, {}).get(&#34;method&#34;)
if method is None:
method = event.get(&#34;requestContext&#34;, {}).get(&#34;httpMethod&#34;)

if method is None:
return not_found()
if method == &#34;GET&#34;:
if self.app.oauth_flow is not None:
oauth_flow: OAuthFlow = self.app.oauth_flow
bolt_req: BoltRequest = to_bolt_request(event)
query = bolt_req.query
is_callback = query is not None and (
(
_first_value(query, &#34;code&#34;) is not None
and _first_value(query, &#34;state&#34;) is not None
)
or _first_value(query, &#34;error&#34;) is not None
)
if is_callback:
bolt_resp = oauth_flow.handle_callback(bolt_req)
return to_aws_response(bolt_resp)
else:
bolt_resp = oauth_flow.handle_installation(bolt_req)
return to_aws_response(bolt_resp)
elif method == &#34;POST&#34;:
bolt_req = to_bolt_request(event)
# https://docs.aws.amazon.com/lambda/latest/dg/python-context.html
aws_lambda_function_name = context.function_name
bolt_req.context[&#34;aws_lambda_function_name&#34;] = aws_lambda_function_name
bolt_req.context[&#34;lambda_request&#34;] = event
bolt_resp = self.app.dispatch(bolt_req)
aws_response = to_aws_response(bolt_resp)
return aws_response
elif method == &#34;NONE&#34;:
bolt_req = to_bolt_request(event)
bolt_resp = self.app.dispatch(bolt_req)
aws_response = to_aws_response(bolt_resp)
return aws_response

return not_found()</code></pre>
</details>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
<nav id="sidebar">
Expand All @@ -91,6 +249,17 @@ <h1>Index</h1>
<li><code><a title="slack_bolt.adapter.aws_lambda.local_lambda_client" href="local_lambda_client.html">slack_bolt.adapter.aws_lambda.local_lambda_client</a></code></li>
</ul>
</li>
<li><h3><a href="#header-classes">Classes</a></h3>
<ul>
<li>
<h4><code><a title="slack_bolt.adapter.aws_lambda.SlackRequestHandler" href="#slack_bolt.adapter.aws_lambda.SlackRequestHandler">SlackRequestHandler</a></code></h4>
<ul class="">
<li><code><a title="slack_bolt.adapter.aws_lambda.SlackRequestHandler.clear_all_log_handlers" href="#slack_bolt.adapter.aws_lambda.SlackRequestHandler.clear_all_log_handlers">clear_all_log_handlers</a></code></li>
<li><code><a title="slack_bolt.adapter.aws_lambda.SlackRequestHandler.handle" href="#slack_bolt.adapter.aws_lambda.SlackRequestHandler.handle">handle</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</main>
Expand Down
87 changes: 86 additions & 1 deletion docs/api-docs/slack_bolt/adapter/bottle/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ <h1 class="title">Module <code>slack_bolt.adapter.bottle</code></h1>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from .handler import SlackRequestHandler # noqa: F401</code></pre>
<pre><code class="python">from .handler import SlackRequestHandler

__all__ = [
&#34;SlackRequestHandler&#34;,
]</code></pre>
</details>
</section>
<section>
Expand All @@ -43,6 +47,77 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
<section>
</section>
<section>
<h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="slack_bolt.adapter.bottle.SlackRequestHandler"><code class="flex name class">
<span>class <span class="ident">SlackRequestHandler</span></span>
<span>(</span><span>app: <a title="slack_bolt.app.app.App" href="../../app/app.html#slack_bolt.app.app.App">App</a>)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class SlackRequestHandler:
def __init__(self, app: App): # type: ignore
self.app = app

def handle(self, req: Request, resp: Response) -&gt; str:
if req.method == &#34;GET&#34;:
if self.app.oauth_flow is not None:
oauth_flow: OAuthFlow = self.app.oauth_flow
if req.path == oauth_flow.install_path:
bolt_resp = oauth_flow.handle_installation(to_bolt_request(req))
set_response(bolt_resp, resp)
return bolt_resp.body or &#34;&#34;
elif req.path == oauth_flow.redirect_uri_path:
bolt_resp = oauth_flow.handle_callback(to_bolt_request(req))
set_response(bolt_resp, resp)
return bolt_resp.body or &#34;&#34;
elif req.method == &#34;POST&#34;:
bolt_resp: BoltResponse = self.app.dispatch(to_bolt_request(req))
set_response(bolt_resp, resp)
return bolt_resp.body or &#34;&#34;

resp.status = 404
return &#34;Not Found&#34;</code></pre>
</details>
<h3>Methods</h3>
<dl>
<dt id="slack_bolt.adapter.bottle.SlackRequestHandler.handle"><code class="name flex">
<span>def <span class="ident">handle</span></span>(<span>self, req: bottle.BaseRequest, resp: bottle.BaseResponse) ‑> str</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def handle(self, req: Request, resp: Response) -&gt; str:
if req.method == &#34;GET&#34;:
if self.app.oauth_flow is not None:
oauth_flow: OAuthFlow = self.app.oauth_flow
if req.path == oauth_flow.install_path:
bolt_resp = oauth_flow.handle_installation(to_bolt_request(req))
set_response(bolt_resp, resp)
return bolt_resp.body or &#34;&#34;
elif req.path == oauth_flow.redirect_uri_path:
bolt_resp = oauth_flow.handle_callback(to_bolt_request(req))
set_response(bolt_resp, resp)
return bolt_resp.body or &#34;&#34;
elif req.method == &#34;POST&#34;:
bolt_resp: BoltResponse = self.app.dispatch(to_bolt_request(req))
set_response(bolt_resp, resp)
return bolt_resp.body or &#34;&#34;

resp.status = 404
return &#34;Not Found&#34;</code></pre>
</details>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
<nav id="sidebar">
Expand All @@ -61,6 +136,16 @@ <h1>Index</h1>
<li><code><a title="slack_bolt.adapter.bottle.handler" href="handler.html">slack_bolt.adapter.bottle.handler</a></code></li>
</ul>
</li>
<li><h3><a href="#header-classes">Classes</a></h3>
<ul>
<li>
<h4><code><a title="slack_bolt.adapter.bottle.SlackRequestHandler" href="#slack_bolt.adapter.bottle.SlackRequestHandler">SlackRequestHandler</a></code></h4>
<ul class="">
<li><code><a title="slack_bolt.adapter.bottle.SlackRequestHandler.handle" href="#slack_bolt.adapter.bottle.SlackRequestHandler.handle">handle</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</main>
Expand Down
Loading

0 comments on commit 647701e

Please sign in to comment.