Skip to content

Commit

Permalink
Update the documents
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Apr 20, 2021
1 parent ac030dd commit 99ed6a6
Show file tree
Hide file tree
Showing 35 changed files with 2,814 additions and 392 deletions.
114 changes: 112 additions & 2 deletions docs/api-docs/slack_bolt/adapter/aws_lambda/chalice_handler.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ <h1 class="title">Module <code>slack_bolt.adapter.aws_lambda.chalice_handler</co
<span>Expand source code</span>
</summary>
<pre><code class="python">import logging
import json
from os import getenv

from chalice.app import Request, Response, Chalice
from chalice.config import Config
from chalice.test import BaseClient, LambdaContext, InvokeResponse

from slack_bolt.adapter.aws_lambda.chalice_lazy_listener_runner import (
ChaliceLazyListenerRunner,
Expand All @@ -41,14 +45,43 @@ <h1 class="title">Module <code>slack_bolt.adapter.aws_lambda.chalice_handler</co
from slack_bolt.response import BoltResponse


class LocalLambdaClient(BaseClient):
&#34;&#34;&#34;Lambda client implementing `invoke` for use when running with Chalice CLI&#34;&#34;&#34;

def __init__(self, app: Chalice, config: Config) -&gt; None:
self._app = app
self._config = config

def invoke(
self,
FunctionName: str = None,
InvocationType: str = &#34;Event&#34;,
Payload: str = &#34;{}&#34;,
) -&gt; InvokeResponse:
scoped = self._config.scope(self._config.chalice_stage, FunctionName)
lambda_context = LambdaContext(
FunctionName, memory_size=scoped.lambda_memory_size
)

with self._patched_env_vars(scoped.environment_variables):
response = self._app(json.loads(Payload), lambda_context)
return InvokeResponse(payload=response)


class ChaliceSlackRequestHandler:
def __init__(self, app: App, chalice: Chalice): # type: ignore
self.app = app
self.chalice = chalice
self.logger = get_bolt_app_logger(app.name, ChaliceSlackRequestHandler)

lambda_client = None
if getenv(&#34;AWS_CHALICE_CLI_MODE&#34;) == &#34;true&#34;:
lambda_client = LocalLambdaClient(self.chalice, Config())

self.app.listener_runner.lazy_listener_runner = ChaliceLazyListenerRunner(
logger=self.logger
logger=self.logger, lambda_client=lambda_client
)

if self.app.oauth_flow is not None:
self.app.oauth_flow.settings.redirect_uri_page_renderer.install_path = &#34;?&#34;

Expand Down Expand Up @@ -205,9 +238,15 @@ <h2 class="section-title" id="header-classes">Classes</h2>
self.app = app
self.chalice = chalice
self.logger = get_bolt_app_logger(app.name, ChaliceSlackRequestHandler)

lambda_client = None
if getenv(&#34;AWS_CHALICE_CLI_MODE&#34;) == &#34;true&#34;:
lambda_client = LocalLambdaClient(self.chalice, Config())

self.app.listener_runner.lazy_listener_runner = ChaliceLazyListenerRunner(
logger=self.logger
logger=self.logger, lambda_client=lambda_client
)

if self.app.oauth_flow is not None:
self.app.oauth_flow.settings.redirect_uri_page_renderer.install_path = &#34;?&#34;

Expand Down Expand Up @@ -338,6 +377,71 @@ <h3>Methods</h3>
</dd>
</dl>
</dd>
<dt id="slack_bolt.adapter.aws_lambda.chalice_handler.LocalLambdaClient"><code class="flex name class">
<span>class <span class="ident">LocalLambdaClient</span></span>
<span>(</span><span>app: chalice.app.Chalice, config: chalice.config.Config)</span>
</code></dt>
<dd>
<div class="desc"><p>Lambda client implementing <code>invoke</code> for use when running with Chalice CLI</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class LocalLambdaClient(BaseClient):
&#34;&#34;&#34;Lambda client implementing `invoke` for use when running with Chalice CLI&#34;&#34;&#34;

def __init__(self, app: Chalice, config: Config) -&gt; None:
self._app = app
self._config = config

def invoke(
self,
FunctionName: str = None,
InvocationType: str = &#34;Event&#34;,
Payload: str = &#34;{}&#34;,
) -&gt; InvokeResponse:
scoped = self._config.scope(self._config.chalice_stage, FunctionName)
lambda_context = LambdaContext(
FunctionName, memory_size=scoped.lambda_memory_size
)

with self._patched_env_vars(scoped.environment_variables):
response = self._app(json.loads(Payload), lambda_context)
return InvokeResponse(payload=response)</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li>chalice.test.BaseClient</li>
</ul>
<h3>Methods</h3>
<dl>
<dt id="slack_bolt.adapter.aws_lambda.chalice_handler.LocalLambdaClient.invoke"><code class="name flex">
<span>def <span class="ident">invoke</span></span>(<span>self, FunctionName: str = None, InvocationType: str = 'Event', Payload: str = '{}') ‑> chalice.test.InvokeResponse</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def invoke(
self,
FunctionName: str = None,
InvocationType: str = &#34;Event&#34;,
Payload: str = &#34;{}&#34;,
) -&gt; InvokeResponse:
scoped = self._config.scope(self._config.chalice_stage, FunctionName)
lambda_context = LambdaContext(
FunctionName, memory_size=scoped.lambda_memory_size
)

with self._patched_env_vars(scoped.environment_variables):
response = self._app(json.loads(Payload), lambda_context)
return InvokeResponse(payload=response)</code></pre>
</details>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
Expand Down Expand Up @@ -368,6 +472,12 @@ <h4><code><a title="slack_bolt.adapter.aws_lambda.chalice_handler.ChaliceSlackRe
<li><code><a title="slack_bolt.adapter.aws_lambda.chalice_handler.ChaliceSlackRequestHandler.handle" href="#slack_bolt.adapter.aws_lambda.chalice_handler.ChaliceSlackRequestHandler.handle">handle</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="slack_bolt.adapter.aws_lambda.chalice_handler.LocalLambdaClient" href="#slack_bolt.adapter.aws_lambda.chalice_handler.LocalLambdaClient">LocalLambdaClient</a></code></h4>
<ul class="">
<li><code><a title="slack_bolt.adapter.aws_lambda.chalice_handler.LocalLambdaClient.invoke" href="#slack_bolt.adapter.aws_lambda.chalice_handler.LocalLambdaClient.invoke">invoke</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
Expand Down
Loading

0 comments on commit 99ed6a6

Please sign in to comment.