================
**aws_snippets**
================
Overview
--------
Python3 classes and functions to execute common AWS operations.
Usage Example
-------------
.. code-block:: BASH
"""Read secret string from AWS Secrets Manager."""
import aws_snippets
# secret_string = aws_snippets.readsecret('<secret-ID>')
secret_string = aws_snippets.readsecret('dkfjh765-sdfsf456-dfgd')
print(secret_string)
# Output: "I'm Batman!"
Get Full Functionality List from Docstring
------------------------------------------
Python Commands:
.. code-block:: BASH
import aws_snippets
help(aws_snippets)
BASH Commands:
.. code-block:: BASH
python -c 'import aws_snippets; help(aws_snippets)'
Output
------
.. code-block:: BASH
Help on package aws_snippets:
NAME
aws_snippets - Execute AWS operations.
PACKAGE CONTENTS
CLASSES
builtins.object
WriteLog
class WriteLog(builtins.object)
| WriteLog(text)
|
| Create JSON log object for CloudWatch.
|
| # Import modules.
| import json
| from aws_snippets import WriteLog
|
| # Initiate with empty dictionary.
| logger = WriteLog({})
|
| # Collect entries to log.
| logger.log('<strkey>', '<value>')
| logger.log('<intkey>', <value>)
| logger.log('<boolkey>', <True/False>)
|
| # Print out to CloudWatch as accumulated log.
| print(json.dumps(logger.text))
|
| Methods defined here:
|
| __init__(self, text)
| Initialize log content.
|
| log(self, key, value)
| Update log content.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
FUNCTIONS
b64encode(cleartext: str, encoding: str = 'latin-1') -> str
Encode strings using Base64.
return str
cfpurge(cf_dist: str, path: str, call_ref: str) -> dict
Create Amazon CloudFront cache invalidation.
return dict
cleantmp(tmppath: str) -> None
Clean Lambda /tmp path.
return None
dynamodbcreatetable(table: str, attrdictls: list, schemadictls: list, kmsid: str, tagdictls: list) -> None
Create a table in DynamoDB.
return None
dynamodbdeleteallitems(table: str) -> None
Delete all items from a DynamoDB table.
return None
dynamodbdeletetable(table: str) -> None
Delete a table from DynamoDB.
return None
dynamodbgetitem(table: str, key: str, value: str) -> dict
Get a single item from DynamoDB.
return dict
dynamodbputitem(table: str, itemdict: dict) -> None
Put a single item into DynamoDB.
return None
dynamodbqueryitems(table: str, key: str, value: str) -> dict
Get items based on keyword query from DynamoDB.
return dict
dynamodbscanallitems(table: str) -> dict
Get all items from a table in DynamoDB.
return dict
dynamodbscanitems(table: str, key: str, value: str, patternexp: dict) -> dict
Get all items from a DynamoDB table then filter by expression.
return dict
dynamodbupdateitem(table: str, keydict: dict, attributedict: dict, valuedict: dict, updateexpression: str) -> dict
Update an item in a DynamoDB table.
return dict
httpget(url: str, headers: dict = {}, encoding: str = 'latin-1') -> dict
Make HTTP requests using GET method.
return dict
httppost(url: str, headers: dict = {}, data: dict = {}, encoding: str = 'latin-1') -> str
Make HTTP requests using POST method.
return str
kmsdecrypt(ciphertext: str, kmsid: str) -> str
Decrypt strings using AWS KMS.
return str
kmsencrypt(cleartext: str, kmsid: str) -> str
Encrypt strings using AWS KMS.
return str
randomize(length: int, punctuations: bool = False) -> str
Create random strings.
return str
readsecret(id: str) -> str
Read secret values in AWS Secrets Manager.
return str
sanitizerclean(input: str) -> str
Sanitize input items.
return str
sanitizercleanlist(input: list, pattern: str) -> list
Sanitize input list.
return list
sanitizercleanurl(url: str) -> str
Sanitize input URLs.
return str
sanitizercleanurllist(input: list, pattern: str) -> list
Sanitize input list.
return list
sanitizervalidate(input: str, pattern: str) -> bool
Validate input items to RegEx patterns.
return bool
sanitizervalidatelist(input: list) -> bool
Validate input list.
return bool
sha3512hash(clrtxt: str, condiments: str, encoding: str = 'latin-1') -> str
Hash strings using SHA3_512 algorithm.
return str
snsnotify(topic: str, message: str, subject: str) -> None
Send AWS SNS notifications.
return None
sqsmessage(queue_url: str, message: dict) -> dict
Send messages into AWS SQS queues.
return dict
DATA
Union = typing.Union
Union type; Union[X, Y] means either X or Y.
To define a union, use e.g. Union[int, str]. Details:
- The arguments must be types and there must be at least one.
- None as an argument is a special case and is replaced by
type(None).
- Unions of unions are flattened, e.g.::
Union[Union[int, str], float] == Union[int, str, float]
- Unions of a single argument vanish, e.g.::
Union[int] == int # The constructor actually returns int
- Redundant arguments are skipped, e.g.::
Union[int, str, int] == Union[int, str]
- When comparing unions, the argument order is ignored, e.g.::
Union[int, str] == Union[str, int]
- You cannot subclass or instantiate a union.
- You can use Optional[X] as a shorthand for Union[X, None].
VERSION
2024.1.0.0
FILE
/Users/abdahmad/Desktop/aws_snippets/__init__.py
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/fer1035_python/modules/pypi-aws_snippets",
"name": "aws_snippets",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6,<4.0",
"maintainer_email": "",
"keywords": "AWS,Python,snippets,operations",
"author": "Ahmad Ferdaus Abd Razak",
"author_email": "ahmad.ferdaus.abd.razak@ni.com",
"download_url": "https://files.pythonhosted.org/packages/a3/70/b34ad99216a5295a50b021a6e8f579ffc8c1caac8f8d7d003d9a7c90dbea/aws_snippets-2024.1.0.0.tar.gz",
"platform": null,
"description": "================\n**aws_snippets**\n================\n\nOverview\n--------\n\nPython3 classes and functions to execute common AWS operations.\n\nUsage Example\n-------------\n\n.. code-block:: BASH\n\n \"\"\"Read secret string from AWS Secrets Manager.\"\"\"\n import aws_snippets\n\n # secret_string = aws_snippets.readsecret('<secret-ID>')\n secret_string = aws_snippets.readsecret('dkfjh765-sdfsf456-dfgd')\n print(secret_string)\n\n # Output: \"I'm Batman!\"\n\nGet Full Functionality List from Docstring\n------------------------------------------\n\nPython Commands:\n\n.. code-block:: BASH\n\n import aws_snippets\n help(aws_snippets)\n\nBASH Commands:\n\n.. code-block:: BASH\n\n python -c 'import aws_snippets; help(aws_snippets)'\n\nOutput\n------\n\n.. code-block:: BASH\n\n Help on package aws_snippets:\n\n NAME\n aws_snippets - Execute AWS operations.\n\n PACKAGE CONTENTS\n\n\n CLASSES\n builtins.object\n WriteLog\n \n class WriteLog(builtins.object)\n | WriteLog(text)\n | \n | Create JSON log object for CloudWatch.\n | \n | # Import modules.\n | import json\n | from aws_snippets import WriteLog\n | \n | # Initiate with empty dictionary.\n | logger = WriteLog({})\n | \n | # Collect entries to log.\n | logger.log('<strkey>', '<value>')\n | logger.log('<intkey>', <value>)\n | logger.log('<boolkey>', <True/False>)\n | \n | # Print out to CloudWatch as accumulated log.\n | print(json.dumps(logger.text))\n | \n | Methods defined here:\n | \n | __init__(self, text)\n | Initialize log content.\n | \n | log(self, key, value)\n | Update log content.\n | \n | ----------------------------------------------------------------------\n | Data descriptors defined here:\n | \n | __dict__\n | dictionary for instance variables (if defined)\n | \n | __weakref__\n | list of weak references to the object (if defined)\n\n FUNCTIONS\n b64encode(cleartext: str, encoding: str = 'latin-1') -> str\n Encode strings using Base64.\n \n return str\n \n cfpurge(cf_dist: str, path: str, call_ref: str) -> dict\n Create Amazon CloudFront cache invalidation.\n \n return dict\n \n cleantmp(tmppath: str) -> None\n Clean Lambda /tmp path.\n \n return None\n \n dynamodbcreatetable(table: str, attrdictls: list, schemadictls: list, kmsid: str, tagdictls: list) -> None\n Create a table in DynamoDB.\n \n return None\n \n dynamodbdeleteallitems(table: str) -> None\n Delete all items from a DynamoDB table.\n \n return None\n \n dynamodbdeletetable(table: str) -> None\n Delete a table from DynamoDB.\n \n return None\n \n dynamodbgetitem(table: str, key: str, value: str) -> dict\n Get a single item from DynamoDB.\n \n return dict\n \n dynamodbputitem(table: str, itemdict: dict) -> None\n Put a single item into DynamoDB.\n \n return None\n \n dynamodbqueryitems(table: str, key: str, value: str) -> dict\n Get items based on keyword query from DynamoDB.\n \n return dict\n \n dynamodbscanallitems(table: str) -> dict\n Get all items from a table in DynamoDB.\n \n return dict\n \n dynamodbscanitems(table: str, key: str, value: str, patternexp: dict) -> dict\n Get all items from a DynamoDB table then filter by expression.\n \n return dict\n \n dynamodbupdateitem(table: str, keydict: dict, attributedict: dict, valuedict: dict, updateexpression: str) -> dict\n Update an item in a DynamoDB table.\n \n return dict\n \n httpget(url: str, headers: dict = {}, encoding: str = 'latin-1') -> dict\n Make HTTP requests using GET method.\n \n return dict\n \n httppost(url: str, headers: dict = {}, data: dict = {}, encoding: str = 'latin-1') -> str\n Make HTTP requests using POST method.\n \n return str\n\n kmsdecrypt(ciphertext: str, kmsid: str) -> str\n Decrypt strings using AWS KMS.\n \n return str\n \n kmsencrypt(cleartext: str, kmsid: str) -> str\n Encrypt strings using AWS KMS.\n \n return str\n \n randomize(length: int, punctuations: bool = False) -> str\n Create random strings.\n \n return str\n \n readsecret(id: str) -> str\n Read secret values in AWS Secrets Manager.\n \n return str\n \n sanitizerclean(input: str) -> str\n Sanitize input items.\n \n return str\n \n sanitizercleanlist(input: list, pattern: str) -> list\n Sanitize input list.\n \n return list\n \n sanitizercleanurl(url: str) -> str\n Sanitize input URLs.\n \n return str\n \n sanitizercleanurllist(input: list, pattern: str) -> list\n Sanitize input list.\n \n return list\n \n sanitizervalidate(input: str, pattern: str) -> bool\n Validate input items to RegEx patterns.\n \n return bool\n \n sanitizervalidatelist(input: list) -> bool\n Validate input list.\n \n return bool\n \n sha3512hash(clrtxt: str, condiments: str, encoding: str = 'latin-1') -> str\n Hash strings using SHA3_512 algorithm.\n \n return str\n \n snsnotify(topic: str, message: str, subject: str) -> None\n Send AWS SNS notifications.\n \n return None\n \n sqsmessage(queue_url: str, message: dict) -> dict\n Send messages into AWS SQS queues.\n \n return dict\n\n DATA\n Union = typing.Union\n Union type; Union[X, Y] means either X or Y.\n \n To define a union, use e.g. Union[int, str]. Details:\n - The arguments must be types and there must be at least one.\n - None as an argument is a special case and is replaced by\n type(None).\n - Unions of unions are flattened, e.g.::\n \n Union[Union[int, str], float] == Union[int, str, float]\n \n - Unions of a single argument vanish, e.g.::\n \n Union[int] == int # The constructor actually returns int\n \n - Redundant arguments are skipped, e.g.::\n \n Union[int, str, int] == Union[int, str]\n \n - When comparing unions, the argument order is ignored, e.g.::\n \n Union[int, str] == Union[str, int]\n \n - You cannot subclass or instantiate a union.\n - You can use Optional[X] as a shorthand for Union[X, None].\n\n VERSION\n 2024.1.0.0\n\n FILE\n /Users/abdahmad/Desktop/aws_snippets/__init__.py\n",
"bugtrack_url": null,
"license": "GPL-2.0-only",
"summary": "Python3 classes and functions to execute common AWS operations.",
"version": "2024.1.0.0",
"project_urls": {
"Homepage": "https://gitlab.com/fer1035_python/modules/pypi-aws_snippets",
"Repository": "https://gitlab.com/fer1035_python/modules/pypi-aws_snippets"
},
"split_keywords": [
"aws",
"python",
"snippets",
"operations"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7775076c4380339c11ec80307741a7033c760edba34c8b688449f9fb3b59d724",
"md5": "013b4e40e6173f45c6f8ac3eb9d08133",
"sha256": "de047a679dc12aeb4622c4ceccc065483a1444dce5ba4f2dfcf2ad35b5ad3abe"
},
"downloads": -1,
"filename": "aws_snippets-2024.1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "013b4e40e6173f45c6f8ac3eb9d08133",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6,<4.0",
"size": 6234,
"upload_time": "2024-02-02T05:32:21",
"upload_time_iso_8601": "2024-02-02T05:32:21.991933Z",
"url": "https://files.pythonhosted.org/packages/77/75/076c4380339c11ec80307741a7033c760edba34c8b688449f9fb3b59d724/aws_snippets-2024.1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a370b34ad99216a5295a50b021a6e8f579ffc8c1caac8f8d7d003d9a7c90dbea",
"md5": "78f4c598cb28bb5c2df78d0f6b09abcc",
"sha256": "38195c9d33c132e8c7c4fa85c78f6b8bf24d5cd939a8c9a6a32ac443a0dc8973"
},
"downloads": -1,
"filename": "aws_snippets-2024.1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "78f4c598cb28bb5c2df78d0f6b09abcc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6,<4.0",
"size": 5340,
"upload_time": "2024-02-02T05:32:23",
"upload_time_iso_8601": "2024-02-02T05:32:23.707129Z",
"url": "https://files.pythonhosted.org/packages/a3/70/b34ad99216a5295a50b021a6e8f579ffc8c1caac8f8d7d003d9a7c90dbea/aws_snippets-2024.1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-02 05:32:23",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "fer1035_python",
"gitlab_project": "modules",
"lcname": "aws_snippets"
}