clearskies-twilio
clearskies bindings for working with Twilio. At the moment it's just an action to send an SMS.
Installation
To install:
pip install clear-skies-twilio
Usage
Authentication
Before you can use this you need to setup authentication to Twilio. This only works with API keys from Twilio - not your auth token(s). Also, this module assumes that your authentication details are stored in your secret manager, so you provide paths to secrets in your secret manager.
IMPORTANT: This module is designed to fetch your Twilio credentials only when needed and will automatically re-fetch them from the secrets manager in the event of an authentication failure. As a result, you can rotate your Twilio credentials at anytime: just drop the new credentials in your secret manager and your running processes will automatically find it and use it without needing to restart/rebuild/relaunch the application. There are three "pieces" to authentication with Twilio:
- API Key
- API Secret
- Account SID
You have to tell the twilio module where these live in the secret manager. We do that in the below example and also point clearskies to AWS Secrets Manager:
import clearskies
import clearskies_twilio
import clearskies_aws
application = clearskies.Application(
SomeHandler,
{
"your": "application config",
},
bindings={
"twilio": clearskies_twilio.di.twilio(
path_to_api_key="/path/to/twilio/api_key",
path_to_api_secret="/path/to/twilio/api_secret",
path_to_account_sid="/path/to/twilio/account_sid",
),
"secrets": clearskies_aws.secrets.SecretsManager,
},
)
Actions
Currently the only option available is an Action for sending SMS messages. It accepts a message that should be a string or a callable that returns the SMS message and which can accept model (the model that triggered the action) as well as any other configured dependencies. You must provide from_number and to_number which can be either a phone number, the name of one of the columns in the model, or callables which return the phone number. Simple example:
import clearskies
from clearskies.column_types import uuid, string, created
from collections import OrderedDict
from clearskies_twilio.actions import sms
class User(clearskies.Model):
def __init__(self, cursor_backend, columns):
super().__init__(cursor_backend, columns)
def columns_configuration(self):
return OrderedDict(
[
uuid("id"),
string("phone"),
string("name"),
created(
"created_at",
on_change=[
sms(
from_number="+15551234567",
to_number="phone",
message=lambda model: f"Welcome {model.name}!"
),
],
),
]
)
Metadata
Release files for clear-skies-twilio 0.9.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clear_skies_twilio-0.9.4.tar.gz | 7.3 kB | Without provenance | Details for clear_skies_twilio-0.9.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clear_skies_twilio-0.9.4-py3-none-any.whl | Python 3 | none | any | Details for clear_skies_twilio-0.9.4-py3-none-any.whl |
Total release size: 15.9 kB
Release files / clear_skies_twilio-0.9.4.tar.gz
| Download URL | clear_skies_twilio-0.9.4.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e448fcc6d62092999b1641b7c564ca9bad958c621ba4c5adfea2556313af009
|
|
BLAKE2b-256 checksum How to use checksums |
c7c0f0b6ccdb05fa0e0ab1a203d664f2526e64ebb9b2d813ae8120481dff06b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.12 Linux/6.5.0-44-generic
|
Release files / clear_skies_twilio-0.9.4-py3-none-any.whl
| Download URL | clear_skies_twilio-0.9.4-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe06cc71a62774ec19adea2129815e7529137eba628589d2ff2dc8ef85c0b052
|
|
BLAKE2b-256 checksum How to use checksums |
0ef0170087f3b037a3b131e684890a09d878a45ed06f2b30aafd590a4a28dbc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.12 Linux/6.5.0-44-generic
|
Security for clear-skies-twilio 0.9.4
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.