{ "info": { "author": "Christopher H. Todd", "author_email": "Christopher.Hayden.Todd@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8" ], "description": "\n\n# Christopher H. Todd's Python Python Library For Interacting With AWS\n\nThe ctodd-python-lib-aws project is responsible for interacting with [Amazon Web Services](https://aws.amazon.com/developer/language/python/). This includes interacting with DynamoDB, Lambda, S3, SNS, and SQS, and will be expanded in the future.\n\nThe library relies on Python's boto3 package which is used to communicate with the AWS APIs and warps the code with exception handling, logging, and other useful and redundant code.\n\n## Table of Contents\n\n- [Dependencies](#dependencies)\n- [Libraries](#libraries)\n- [Example Scripts](#example-scripts)\n- [Notes](#notes)\n- [TODO](#todo)\n\n## Dependencies\n\n### Python Packages\n\n- boto3>=1.7.32\n- botocore>=1.12.71\n- wrapt>=1.10.8\n\n## Libraries\n\n### [dynamodb_helpers.py](https://github.com/ChristopherHaydenTodd/ctodd-python-lib-aws/blob/master/aws_helpers/dynamodb_helpers.py)\n\nHelper Library for AWS DynamoDB Service. Will provide a functions for interacting with the Resource and Client APIs through Boto3\n\nFunctions:\n\n```\ndef create_dynamodb_resource(region_name=None, access_key=None, secret_key=None):\n \"\"\"\n Purpose:\n Return a DynamoDB resource object.\n Args:\n region_name (String): Name of region to connect to\n access_key (String): access key to use to connect to DynamoDB Resource\n secret_key (String): secret key to use to connect to DynamoDB Resource\n Return:\n dynamodb (DynamoDB Resource Object): DynamoDB Resource Object\n \"\"\"\n```\n\n```\ndef get_table(dynamodb, table_name):\n \"\"\"\n Purpose:\n Return an DynamoDB Table by name\n Args:\n dynamodb (DynamoDB Resource Object): DynamoDB Object owning the Table\n table_name (String): Name of table to return\n Return:\n table (DynamoDB Table Object): Table object for the table in\n DynamoDB\n \"\"\"\n```\n\n```\ndef get_table_names(dynamodb):\n \"\"\"\n Purpose:\n Return an Table Names in DynamoDB\n Args:\n dynamodb (DynamoDB Resource Object): DynamoDB Object owning the Table\n Return:\n table_names (List of Strings): Name of tables in DynamoDB\n \"\"\"\n```\n\n```\ndef create_table(dynamodb, table_name, partition_key, sort_key={}, rcu=15, wcu=5):\n \"\"\"\n Purpose:\n Create an DynamoDB Table by name\n Args:\n dynamodb (DynamoDB Resource Object): DynamoDB Object owning the Table\n table_name (String): Name of table to return\n partition_key (Dict): Dict with name and type of the partition key\n e.g. {\"name\": \"name_of_partition_key\", \"type\": \"S\"}\n sort_key (Dict): Dict with name and type of the sort key\n e.g. {\"name\": \"name_of_sort_key\", \"type\": \"S\"}\n rcu (Int): Read Capacity Units for the table. Defaults to 15\n wcu (Int): Write Capacity Units for the table. Defaults to 5\n Return:\n table (DynamoDB Table Object): Created Table Object\n \"\"\"\n```\n\n```\ndef delete_table(table):\n \"\"\"\n Purpose:\n Delete an DynamoDB Table\n Args:\n table (DynamoDB Table Object): Table to delete\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef check_table_exists_and_active(dynamodb, table_name):\n \"\"\"\n Purpose:\n Check if Table exists and is active. When a table is created,\n it is not yet active. Active will define the table as fully\n created.\n Args:\n dynamodb (DynamoDB Resource Object): DynamoDB Object owning the Table\n table_name (String): Name of table to check for\n Return:\n table_exists (Boolean): Whether or not the table exists in DynamoDB\n table_active (Boolean): Whether or not the table is active in DynamoDB (fully\n created and ready for use)\n \"\"\"\n```\n\n```\ndef insert_record(table, record):\n \"\"\"\n Purpose:\n Insert single record into DynamoDB table\n Args:\n table (DynamoDB Table Object): Table object for the table in\n DynamoDB\n record (Dict): Single to insert/update in the table\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef insert_records(table, records):\n \"\"\"\n Purpose:\n Batch insert records into database\n Args:\n table (DynamoDB Table Object): Table object for the table in\n DynamoDB\n records (List of Dict): List of records to insert/update in the\n table\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef delete_record(table, query):\n \"\"\"\n Purpose:\n Delete single record into DynamoDB table\n Args:\n table (DynamoDB Table Object): Table object for the table in\n DynamoDB\n query (Dict): Delete specifications (field and values to match\n record and delete)\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef get_records(table, query):\n \"\"\"\n Purpose:\n Return Records from a Table\n Args:\n table (DynamoDB Table Object): Table object for the table in\n DynamoDB\n Return:\n ?\n \"\"\"\n```\n\n### [lambda_helpers.py](https://github.com/ChristopherHaydenTodd/ctodd-python-lib-aws/blob/master/aws_helpers/lambda_helpers.py)\n\nHelper Library for AWS Lambda Service. Will provide a functions for interacting with the Resource and Client APIs through Boto3\n\nFunctions:\n\n```\ndef get_bucket_name_from_s3_event(event):\n \"\"\"\n Purpose:\n Get the S3 Bucket name from an event triggered by the creation\n of an object in S3\n Args:\n event (Dict): Dict with event details from the triggering event\n for the function.\n Return:\n bucket_name (String): Bucket name of the object creation triggering\n the call to the Lambda function\n \"\"\"\n```\n\n```\ndef get_object_key_from_s3_event(event):\n \"\"\"\n Purpose:\n Get the S3 Bucket name from an event triggered by the creation\n of an object in S3\n Args:\n event (Dict): Dict with event details from the triggering event\n for the function.\n Return:\n bucket_name (String): Bucket name of the object creation triggering\n the call to the Lambda function\n \"\"\"\n```\n\n### [s3_helpers.py](https://github.com/ChristopherHaydenTodd/ctodd-python-lib-aws/blob/master/aws_helpers/s3_helpers.py)\n\nHelper Library for AWS S3 Service. Will provide a functions for interacting with the Resource and Client APIs through Boto3\n\nFunctions:\n\n```\ndef create_s3_resource(region_name=None, access_key=None, secret_key=None):\n \"\"\"\n Purpose:\n Return a S3 resource object.\n Args:\n region_name (String): Name of region to connect to\n access_key (String): access key to use to connect to S3 Resource\n secret_key (String): secret key to use to connect to S3 Resource\n Return:\n s3 (S3 Resource Object): S3 Resource Object\n \"\"\"\n```\n\n```\ndef get_bucket(s3, bucket_name):\n \"\"\"\n Purpose:\n Return an S3 Bucket by name\n Args:\n s3 (S3 Resource Object): S3 Object owning the Bucket\n bucket_name (String): Name of bucket to return\n Return:\n bucket (S3 Bucket Object): Bucket object for the bucket in\n S3\n \"\"\"\n```\n\n```\ndef get_bucket_names(s3):\n \"\"\"\n Purpose:\n Return an Bucket Names in S3\n Args:\n s3 (S3 Resource Object): S3 Object owning the Bucket\n Return:\n bucket_names (List of Strings): Name of buckets in S3\n \"\"\"\n```\n\n```\ndef create_bucket(s3, bucket_name, region_name=None):\n \"\"\"\n Purpose:\n Create an S3 Bucket by name\n Args:\n s3 (S3 Resource Object): S3 Object owning the Bucket\n bucket_name (String): Name of bucket to return\n region_name (String): Region to create bucket in\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef delete_bucket(bucket, force=True):\n \"\"\"\n Purpose:\n Delete an S3 Bucket\n Args:\n bucket (S3 Bucket Object): Bucket to upload file to\n force (Boolean): Whether or not to delete all objects in\n the bucket to force the delete. If false, will try to\n delete and fail if there are objects in the bucket\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef download_file(bucket, key, filename=None):\n \"\"\"\n Purpose:\n Download a File to an S3 bucket\n Args:\n bucket (S3 Bucket Object): Bucket to download file from\n key (String): Name of the object in S3\n filename (String): Path to the file on the local host\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef upload_file(bucket, key, filename, encryption=None):\n \"\"\"\n Purpose:\n Upload a File to an S3 bucket\n Args:\n bucket (S3 Bucket Object): Bucket to upload file to\n key (String): Desired name of the object in S3\n filename (String): Path to the file on the local host\n encryption (String): Server Side Encryption Method\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef delete_all_files_in_bucket(bucket):\n \"\"\"\n Purpose:\n Delete all files in a Bucket\n Args:\n bucket (S3 Bucket Object): Bucket to delete files from\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef generate_presigned_url(s3, bucket_name, key, url_expire=900):\n \"\"\"\n Purpose:\n Return a presigned URL to a file\n Args:\n s3 (S3 Resource Object): S3 Resource Object\n bucket_name (String): Name of bucket in S3 with Object\n key (String): Name of the object in S3\n url_expire (int): Number of seconds for the URL to live\n Returns:\n presigned_url (String): Presigned URL\n \"\"\"\n```\n\n### [sns_helpers.py](https://github.com/ChristopherHaydenTodd/ctodd-python-lib-aws/blob/master/aws_helpers/sns_helpers.py)\n\nHelper Library for AWS SNS Service. Will provide a functions for interacting with the Resource and Client APIs through Boto3\n\nFunctions:\n\n```\ndef create_sns_resource(region_name=None, access_key=None, secret_key=None):\n \"\"\"\n Purpose:\n Return a SNS resource object.\n Args:\n region_name (String): Name of region to connect to\n access_key (String): access key to use to connect to SNS Resource\n secret_key (String): secret key to use to connect to SNS Resource\n Return:\n dynamodb (SNS Resource Object): SNS Resource Object\n \"\"\"\n```\n\n```\ndef get_topic(sns, topic_arn):\n \"\"\"\n Purpose:\n Return an SNS Topic by ARN\n Args:\n sns (SNS Resource Object): SNS Object owning the Topic\n topic_arn (String): ARN of the Topic\n Return:\n topic (SNS Topic Object): Topic object for the topic in\n SNS\n \"\"\"\n```\n\n```\ndef send_email_notification(topic, email_subject, email_msg):\n \"\"\"\n Purpose:\n Send an email notification utilizing the SNS service\n Args:\n topic (SNS Topic Object): Topic object for the bucket in\n SNS\n email_subject (String): Subject of the email\n email_msg (String): Message Body of the email\n Return:\n N/A\n \"\"\"\n```\n\n### [sqs_consumer.py](https://github.com/ChristopherHaydenTodd/ctodd-python-lib-aws/blob/master/aws_helpers/sqs_consumer.py)\n\nSQS Consumer Class. Will provide functionality to consume from SQS Queues in AWS\n\nClasses:\n\n```\nclass SQSConsumer(object):\n \"\"\"\n SQSConsumer Class\n \"\"\"\n```\n\nFunctions:\n\n#### N/A\n\n### [sqs_helpers.py](https://github.com/ChristopherHaydenTodd/ctodd-python-lib-aws/blob/master/aws_helpers/sqs_helpers.py)\n\nHelper Library for AWS SQS Service. Will provide a functions for interacting with the Resource and Client APIs through Boto3\n\nFunctions:\n\n```\ndef create_sqs_resource(region_name=None, access_key=None, secret_key=None):\n \"\"\"\n Purpose:\n Return a SQS resource object.\n Args:\n region_name (String): Name of region to connect to\n access_key (String): access key to use to connect to SQS Resource\n secret_key (String): secret key to use to connect to SQS Resource\n Return:\n sqs (SQS Resource Object): SQS Resource Object\n \"\"\"\n```\n\n```\ndef get_queue(sqs, queue_name):\n \"\"\"\n Purpose:\n Return an SQS Queue by Queue Name\n Args:\n sqs (SQS Resource Object): SQS Resource Object\n queue_name (String): Name of Queue\n Return:\n queue (SQS Queue Object): Queue object for the queue in\n SQS\n \"\"\"\n```\n\n```\ndef get_messages(queue, max_msgs=10, wait_time=20, attr_names=[\"All\"]):\n \"\"\"\n Purpose:\n Get messages in an SQS Queue\n Args:\n queue (SQS Queue Object): Queue object for the queue in\n SQS\n max_msgs (Int): Max messages to pull at once\n wait_time (Int): Seconds to wait for a message if queues are empty\n attr_names (List of Strings): Filter for messages to pull (if applicable)\n Return:\n messages ()\n \"\"\"\n```\n\n```\ndef delete_message(msg):\n \"\"\"\n Purpose:\n Delete Message an SQS Queue\n Args:\n msg (SQS Message Object): Message in SQS\n Return:\n N/A\n \"\"\"\n```\n\n\n## Example Scripts\n\nExample executable Python scripts/modules for testing and interacting with the library. These show example use-cases for the libraries and can be used as templates for developing with the libraries or to use as one-off development efforts.\n\n### N/A\n## Notes\n\n - Relies on f-string notation, which is limited to Python3.6. A refactor to remove these could allow for development with Python3.0.x through 3.5.x\n\n## TODO\n\n - Unittest framework in place, but lacking tests\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ChristopherHaydenTodd/ctodd-python-lib-aws", "keywords": "python,libraries,aws,S3,SNS,SQS", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "ctodd-python-lib-aws", "package_url": "https://pypi.org/project/ctodd-python-lib-aws/", "platform": "", "project_url": "https://pypi.org/project/ctodd-python-lib-aws/", "project_urls": { "Homepage": "https://github.com/ChristopherHaydenTodd/ctodd-python-lib-aws" }, "release_url": "https://pypi.org/project/ctodd-python-lib-aws/1.0.0/", "requires_dist": [ "wrapt (>=1.10.8)", "boto3 (>=1.7.32)", "botocore (>=1.12.71)" ], "requires_python": ">3.6", "summary": "Python utilities used for interacting with Amazon Web Services", "version": "1.0.0" }, "last_serial": 5105745, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "05610e1e108e1de02cd58d81a1a25b51", "sha256": "150d39b4d01d02e19b66926dbd3a8578fe65f2ad8efeee5dc1168562996e0f44" }, "downloads": -1, "filename": "ctodd_python_lib_aws-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "05610e1e108e1de02cd58d81a1a25b51", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">3.6", "size": 15309, "upload_time": "2019-04-05T21:27:51", "url": "https://files.pythonhosted.org/packages/85/49/824a2b82cefd1f39724adadda9e1d523686fe7bef96194b92118da028d11/ctodd_python_lib_aws-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8a24d01a3cdc13bcc0a455e7f715f1a0", "sha256": "8618af29096021be4b7bd3da45594ca588e84ae03f476e0365be296372479628" }, "downloads": -1, "filename": "ctodd-python-lib-aws-1.0.0.tar.gz", "has_sig": false, "md5_digest": "8a24d01a3cdc13bcc0a455e7f715f1a0", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 10884, "upload_time": "2019-04-05T21:27:53", "url": "https://files.pythonhosted.org/packages/3a/d7/8a6fa097d8d7a0feb4e8dba204650c043859a493d3a8151aa7127874a51e/ctodd-python-lib-aws-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "05610e1e108e1de02cd58d81a1a25b51", "sha256": "150d39b4d01d02e19b66926dbd3a8578fe65f2ad8efeee5dc1168562996e0f44" }, "downloads": -1, "filename": "ctodd_python_lib_aws-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "05610e1e108e1de02cd58d81a1a25b51", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">3.6", "size": 15309, "upload_time": "2019-04-05T21:27:51", "url": "https://files.pythonhosted.org/packages/85/49/824a2b82cefd1f39724adadda9e1d523686fe7bef96194b92118da028d11/ctodd_python_lib_aws-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8a24d01a3cdc13bcc0a455e7f715f1a0", "sha256": "8618af29096021be4b7bd3da45594ca588e84ae03f476e0365be296372479628" }, "downloads": -1, "filename": "ctodd-python-lib-aws-1.0.0.tar.gz", "has_sig": false, "md5_digest": "8a24d01a3cdc13bcc0a455e7f715f1a0", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 10884, "upload_time": "2019-04-05T21:27:53", "url": "https://files.pythonhosted.org/packages/3a/d7/8a6fa097d8d7a0feb4e8dba204650c043859a493d3a8151aa7127874a51e/ctodd-python-lib-aws-1.0.0.tar.gz" } ] }