Library for managing and deploying a lightweight approval workflow based on Slack and GCP
Project description
slack_approval
This python library serves as the basis for managing and deploying a lightweight approval workflow based on Slack and GCP. This library contains two key classes, SlackRequest
and SlackProvision
as well as the logic to deploy them to GCP, which is based on goblet.
Slack Approval Flow
The user iniates a request to the reqest function. This function uses the SlackRequest
class to then post a message into a private Slack channel with the option to approve or reject the request.
Sample message in the approvers channel.
If approved by a member of the private channel, the message is then sent to the provision function, which executes logic based on the request. There is a second Slack channel for requesters to view the status of their request.
Onboarding New Requests for Approval
Provision
- First add a provision file for your new request
provision_{request name}.py
- In the file, extend the
from slack_approval.slack_provision import SlackProvision
class and define your ownapproved()
and optionally arejected()
method. By default, rejections log the event in the function and updates the messages in Slack. You only need to define it if other actions are necessary. - Import your new class in
provision.py
. This should be the only thing you need to change anything else in the base files
Request
- The only requirement for the events sent to the request function is the
provision_class
field. This is what maps the event to the right class in the provision function. You can add any other fields here and they will show up in the request in Slack.-
The value for
provision_class
should be the name of your provision class with spacesie. class
ProvisionLBEndpoint
->"provision_class": "Provision LB Endpoint"
-
Example:
curl -X POST -H "Content-Type:application/json" https://REGION-PROJECT.cloudfunctions.net/slack-request -d '{
"provision_class": "Provision Service",
"field1": "value1",
"field2": "value2",
}'
- The entire data json is available to the provision classes as
self.inputs
Deploying Functions
The functions that need to be deployed are found in the /functions
folder or can be created by the slack_approval init
command.
See the blog post Tutorial: Setting Up Approval Processes with Slack Apps for more detailed slack and GCP setup steps.
Before deploying you will need to modify the config.json
file found in the .goblet
folder with the required environment variables.
Request
- APPROVERS_CHANNEL
- REQUESTERS_CHANNEL
- SLACK_BOT_TOKEN
Provision
- SLACK_BOT_TOKEN
To deploy the functions all you need to do is run the following two commands.
-
goblet deploy --stage request
-
goblet deploy --stage provision
Blog post
See the blog post Tutorial: Setting Up Approval Processes with Slack Apps for more detailed slack and GCP setup steps.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file slack_approval-0.1.0.tar.gz
.
File metadata
- Download URL: slack_approval-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a875d3de1a572870eb6f3e1f710f43aa312bec3ca2bab925a776213f55ddac64 |
|
MD5 | 9ecdcd47915785edc6600253a6987892 |
|
BLAKE2b-256 | 5f3b4904617ca2fd5b74fc8321f83393f3552e40b874849e6d4e6d2ee8666394 |
File details
Details for the file slack_approval-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: slack_approval-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06b1a076d33cac044438f6c4f443d6a956b03cc727ee47615cc46194ed3dcbfb |
|
MD5 | f4e2e1c0f9cd49c21b19bf78a0b62ca5 |
|
BLAKE2b-256 | 2fba8a8f4eef96439caf9c564a2972ae7f283303e9707f7bc2a9a46513addb94 |