|
1 |
| -## AWS Serverless Application Repository - Python |
| 1 | +# AWS Serverless Application Repository - Python |
2 | 2 |
|
3 |
| -A Python library with convenience helpers for working with the AWS Serverless Application Repository. |
| 3 | +A Python library with convenience helpers for working with the [AWS Serverless Application Repository](https://aws.amazon.com/serverless/serverlessrepo/). |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +Simply use pip to install the library: |
| 8 | + |
| 9 | +``` |
| 10 | +pip install serverlessrepo |
| 11 | +``` |
| 12 | + |
| 13 | +## Basic Usage |
| 14 | + |
| 15 | +The serverlessrepo module provides a simple interface for publishing applications and managing application permissions. To get started, import the serverlessrepo module: |
| 16 | + |
| 17 | +```python |
| 18 | +import serverlessrepo |
| 19 | +``` |
| 20 | + |
| 21 | +### Publish Applications |
| 22 | + |
| 23 | +#### publish_application(template) |
| 24 | + |
| 25 | +Given an [AWS Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md) template, it publishes a new application using the specified metadata in AWS Serverless Application Repository. If the application already exists, it publishes a new application version. |
| 26 | + |
| 27 | +#### publish_application_metadata(template, application_id) |
| 28 | + |
| 29 | +Parses the application metadata from the SAM template and updates the application. |
| 30 | + |
| 31 | +#### Examples |
| 32 | + |
| 33 | +Publish an application using local file template.yaml: |
| 34 | + |
| 35 | +```python |
| 36 | +from serverlessrepo import publish_application |
| 37 | + |
| 38 | +with open('template.yaml', 'r') as f: |
| 39 | + template = f.read() |
| 40 | + publish_application(template) |
| 41 | +``` |
| 42 | + |
| 43 | +Or updates the application's metadata using template.yaml: |
| 44 | + |
| 45 | +```python |
| 46 | +from serverlessrepo import publish_application_metadata |
| 47 | + |
| 48 | +with open('template.yaml', 'r') as f: |
| 49 | + template = f.read() |
| 50 | + application_id = 'arn:aws:serverlessrepo:us-east-1:123456789012:applications/test-app' |
| 51 | + publish_application_metadata(template, application_id) |
| 52 | +``` |
| 53 | + |
| 54 | +### Manage Application Permissions |
| 55 | + |
| 56 | +#### make_application_public(application_id) |
| 57 | + |
| 58 | +Makes an application public so that it's visible to everyone. |
| 59 | + |
| 60 | +#### make_application_private(application_id) |
| 61 | + |
| 62 | +Makes an application private so that it's only visible to the owner. |
| 63 | + |
| 64 | +#### share_application_with_accounts(application_id, account_ids) |
| 65 | + |
| 66 | +Shares the application with specified AWS accounts. |
| 67 | + |
| 68 | +#### Examples |
| 69 | + |
| 70 | +```python |
| 71 | +from serverlessrepo import ( |
| 72 | + make_application_public, |
| 73 | + make_application_private, |
| 74 | + share_application_with_accounts |
| 75 | +) |
| 76 | + |
| 77 | +application_id = 'arn:aws:serverlessrepo:us-east-1:123456789012:applications/test-app' |
| 78 | + |
| 79 | +# Share an application publicly |
| 80 | +make_application_public(application_id) |
| 81 | + |
| 82 | +# Make an application private |
| 83 | +make_application_private(application_id) |
| 84 | + |
| 85 | +# Share an application with other AWS accounts |
| 86 | +share_application_with_accounts(application_id, ['123456789013', '123456789014']) |
| 87 | +``` |
| 88 | + |
| 89 | +## Development |
| 90 | + |
| 91 | +* Clone the project to your local: |
| 92 | + * `git clone https://github.com/awslabs/aws-serverlessrepo-python.git` |
| 93 | +* Set up the environment: `make init` |
| 94 | + * It installs [Pipenv](https://github.com/pypa/pipenv) to manage package dependencies. Then it creates a virtualenv and installs dependencies from [Pipfile](./Pipfile) (including dev). |
| 95 | +* Install new packages: `pipenv install [package names]` |
| 96 | + * Pipenv will automatically update [Pipfile](./Pipfile) and [Pipfile.lock](./Pipfile.lock) for you. |
| 97 | + * Add new dependencies to [setup.py](./setup.py) install_requires if they are needed for consumers of this library. |
| 98 | +* Verify that everything works: `make build` |
| 99 | + * You can run `make tests` separately to verify that tests pass. |
| 100 | + * Check code style with `make flake` and `make lint`. |
| 101 | +* Make code changes, run all verifications again before sending a Pull Request: `make pr` |
4 | 102 |
|
5 | 103 | ## License
|
6 | 104 |
|
7 |
| -This library is licensed under the Apache 2.0 License. |
| 105 | +This library is licensed under the Apache 2.0 License. |
0 commit comments