semvec/pypi-packages huggingface dataset:
cfn_resource 0.2.3
Wrapper decorators for building CloudFormation custom resources
License: MIT
Keywords: cloudformation aws cloud custom resource amazon

## cfn_resource.py

This project is a decorator and validation system that takes the drudgery out
of writing custom resources. You still have access to the context and event as
normal, but the decorator handles serializing your response and communicating
results to CloudFormation.

See [cfn-lambda](https://github.com/andrew-templeton/cfn-lambda) from Andrew
Templeton if you're looking to write your custom resources in Node.js.

## Usage

1. Copy `cfn_resource.py` into the directory of your lambda function handler.py
1. Use the `cfn_resource.Resource` event decorators to decorate your handler
   like in `example.py`
1. Zip up the contents and upload to Lambda

Once the function is up, copy its ARN and use it as the ServiceToken for your
[custom resource][rsrc]. For more on the requests you may receive, see
[this document][reqdocs]

```json
{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Resources": {
        "FakeThing": {
            "Type": "Custom::MyResource",
            "Properties": {
                "ServiceToken": "arn:aws:lambda:SOME-REGION:ACCOUNT:function:FunctionName",
                "OtherThing": "foobar",
                "AnotherThing": 2
            }
        }
    }
}
```

For more on how custom resources work, see the [AWS docs][docs]

## Code Sample

For this example, you need to have your handler in Lambda set as
`filename.handler` where filename has the below contents.

```
import cfn_resource

# set `handler` as the entry point for Lambda
handler = cfn_resource.Resource()

@handler.create
def create_thing(event, context):
    # do some stuff
    return {"PhysicalResourceId": "arn:aws:fake:myID"}

@handler.update
def update_thing(event, context):
    # do some stuff
    return {"PhysicalResourceId": "arn:aws:fake:myID"}
```

## Running Tests

To run the tests locally, you need Python 2.7 and `pip`. Ideally, you should
use a virtualenv.

```
$ pip install -r test-requirements.txt
$ py.test
```

The tests use `mock` and `py.test` and will give you a terminal coverage
report. Currently the tests cover ~90% of the (very small) codebase.

## License

This code is released under the MIT software license, see LICENSE.txt for
details. No warranty of any kind is included, and the copyright notice must be
included in redistributions.

[rsrc]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cfn-customresource.html
[docs]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html
[reqdocs]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html
fh-django-sendgrid-gae 0.2.1
SendGrid Backend for Django on GAE using task queues
License: MIT

Django-SendGrid-GAE
===============

Simple Django backend to send email using SendGrid's Web API on GAE using task queues.

Installation
------------

Install the backend from PyPI:

.. code:: bash

    pip install fh-django-sendgrid-gae

Add the following to your project's **settings.py**:

.. code:: python

    EMAIL_BACKEND = "sgbackend.SendGridBackend"
    SENDGRID_API_KEY = "Your SendGrid API Key"

**Done!**

Example
-------

.. code:: python


    from django.core.mail import send_mail
    from django.core.mail import EmailMultiAlternatives

    send_mail("Your Subject", "This is a simple text email body.",
      "Test User <test@example.com>", ["test@example.com"])

    # or
    mail = EmailMultiAlternatives(
      subject="Your Subject",
      body="This is a simple text email body.",
      from_email="Test User <test@example.com>",
      to=["test@example.com"],
      headers={"Reply-To": "tester@example.com"}
    )
    # Add template
    mail.template_id = 'YOUR TEMPLATE ID FROM SENDGRID ADMIN'

    # Replace substitutions in sendgrid template
    mail.substitutions = {'%username%': 'testuser'}

    # Attach file
    with open('somefilename.pdf', 'rb') as file:
        mail.attachments = [
            ('somefilename.pdf', file.read(), 'application/pdf')
        ]

    mail.attach_alternative(
        "<p>This is a simple HTML email body</p>", "text/html"
    )

    mail.send()


License
-------
MIT


Enjoy :)