Skip to main content

slack_approval

PyPI PyPI - Python Version

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.

Install library with pip install slack_approval

Slack Approval Flow


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.

sample_message

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 own approved() and optionally a rejected() 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 spaces

      ie. class ProvisionLBEndpoint -> "provision_class": "Provision LB Endpoint"

  • Optionally, you can add approvers_channel and requesters_channel fields in your request to specify the approvers and requesters channels respectively.
    • If added, add environment variables with the same values.
    • If not provided, the function will look for APPROVERS_CHANNEL and REQUESTERS_CHANNEL environment variables by default.

Example:

curl -X POST -H "Content-Type:application/json" https://REGION-PROJECT.cloudfunctions.net/slack-request -d '{
	"provision_class": "Provision Service",
    "approvers_channel": "APPROVERS_CHANNEL",
    "requesters_channel": "REQUESTERS_CHANNEL",
	"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.

Metadata

Release files for slack-approval 0.1.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slack-approval 0.1.7.0
File Size Uploaded Provenance Actions
slack_approval-0.1.7.0.tar.gz 10.8 kB Without provenance Details for slack_approval-0.1.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for slack-approval 0.1.7.0
File Interpreter ABI Platform Actions
slack_approval-0.1.7.0-py3-none-any.whl Python 3 none any Details for slack_approval-0.1.7.0-py3-none-any.whl

Total release size: 20.7 kB

Release files / slack_approval-0.1.7.0.tar.gz

Download URL slack_approval-0.1.7.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ab6f1bec1566cad6fee98731a636ef72501534e02ed7d6e0712701f0bbe717c2
BLAKE2b-256 checksum
How to use checksums
8b31918414e903bd8b83ee5a3fcf8f991adaee75d3c98717db9016683b425513
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / slack_approval-0.1.7.0-py3-none-any.whl

Download URL slack_approval-0.1.7.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
148dc371b24549e152f2198d9af89f9abaadd0e8ae25e5d52c11418dd6f73b3f
BLAKE2b-256 checksum
How to use checksums
67491046fbcbdf548442439f3490425c8b15d9269565494406bda29a14b8247b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for slack-approval 0.1.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page