{ "info": { "author": "Joseph Wortmann", "author_email": "jwortmann@quinovas.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.7" ], "description": "# Botoinator\n\n### A python module that allows for declaring decorators to be added to boto3 methods\n\n\n## Overview\n Botoinator allows you to apply decorators to boto3 methods on either a class or object level. It works through boto3 sessions to allow you to apply decorators to either all clients/resources of a particular session, or to specific clients/resources of boto3.DEFAULT_SESSION.\n\n## Generated documentation\nYou can see the pydoc generated documentation [HERE](https://github.com/QuiNovas/botoinator/tree/master/documentation/botoinator.txt)\n\n# Usage\n### Decorate a method belonging to a client object to a single session\n```python\nsession = boto3.session.Session()\nsession.register_client_decorator(service_name, method_names, decorator)\n```\nArguments:\n* service_name -- the boto3 name (as a string) of the client to apply the decorator to.\n* method_names -- one or more method names of the client to apply the decorator to. Single names can be a string, while multiple names can be a list/tuple/set.\n* decorator -- the decorator function. Must be a function that takes a function and returns a function. The returned function must take (*args, **kwargs) as arguments.\n\n### Decorate a method belonging to a resource object in a single session\n```python\nsession = boto3.session.Session()\nsession.register_resource_decorator(service_name, resource_name, method_names, decorator)\n```\nArguments:\n* service_name -- the boto3 name (as a string) of the service to apply the decorator to.\n* resource_name -- the boto3 name of the resource of the service to apply the decorator to.\n* method_names -- one or more method names of the resource to apply the decorator to. Single names can be a string, while multiple names should be a list/tuple/set.\n* decorator -- the decorator function. Must be a function that takes a function and returns a function. The returned function must take (*args, **kwargs) as arguments\n\n### Decorate a method for clients created in any session\n```python\nboto3.session.Session.add_client_decorator(service_name, method_names, decorator)\n```\nArguments:\n* service_name -- the boto3 name (as a string) of the client to apply the decorator to.\n* method_names -- one or more method names of the client to apply the decorator to. Single names can be a string, while multiple names should be a list/tuple/set.\n* decorator -- the decorator function. Must be a function that takes a function and returns a function. The returned function must take (*args, **kwargs) as arguments.\n\n### Decorate a method of a resource in all sessions\n```python\nboto3.session.Session.add_resource_decorator(service_name, resource_name, method_names, decorator)\n```\nArguments:\n* service_name -- the boto3 name of the service to apply the decorator to.\n* resource_name -- the boto3 name of the resource of the service to apply the decorator to.\n* method_names -- one or more method names of the resource to apply the decorator to. Single names can be a string, while multiple names should be a list/tuple/set\n* decorator -- the decorator function. Must be a function that takes a function and returns a function. The returned function must take (*args, **kwargs) as arguments\n\n### Unregister a decorator so that future clients will not have their methods decorated. Clients that have already registered decorators to methods will retain their decoration.\n```python\nsession = boto3.session.Session()\nsession.unregister_client_decorator(service_name, method_names)\n```\nArguments:\n* service_name -- the boto3 name of the service to apply the decorator to.\n* method_names -- one or more method names of the client to apply the decorator to. Single names can be a string, while multiple names should be a list/tuple/set\n\n### Unregister a decorator so that future resources will not have their methods decorated. Resources that have already registered decorators to methods will retain their decoration.\n```python\nsession = boto3.session.Session()\nsession.unregister_resource_decorator(service_name, resource_name, method_names)\n```\nArguments:\n* service_name -- the boto3 name of the service to apply the decorator to.\n* resource_name -- the boto3 name of the resource of the service to apply the decorator to.\n* method_names -- one or more method names of the resource to apply the decorator to. Single names can be a string, while multiple names should be a list/tuple/set\n\n### Undecorate a method for clients created in any session.\n```python\nboto3.session.Session.remove_client_decorator(service_name, method_names)\n```\nArguments:\n* service_name -- the boto3 name (as a string) of the client to apply the decorator to.\n* method_names -- one or more method names of the client to apply the decorator to. Single names can be a string, while multiple names should be a list/tuple/set.\n\n### Undecorate a method of a resource in all sessions\n```python\nboto3.session.Session.remove_resource_decorator(service_name, resource_name, method_names)\n```\nArguments:\n* service_name -- the boto3 name of the service to apply the decorator to.\n* resource_name -- the boto3 name of the resource of the service to apply the decorator to.\n* method_names -- one or more method names of the resource to apply the decorator to. Single names can be a string, while multiple names should be a list/tuple/set\n\n# boto3 convienence methods\nIf you use the ```boto3.client()``` or ```boto3.resource()``` methods, these create a default session object found at ```boto3.DEFAULT_SESSION```.\nChanging the default session's decorators requires using the ```register_xxx``` and ```unregister_xxx``` methods documented here.\nFor example ```boto3.DEFAULT_SESSION.register_client_decorator(...)```.\n\n## Example of decorating create_bucket() on a single boto3 session\n```python\nimport boto3\nimport botoinator\nfrom moto import mock_s3, mock_sqs\n\n\"\"\" This is our decorator that we will apply to boto3 methods \"\"\"\ndef myDecorator(func):\n def test_decorator(*args, **kwargs):\n setattr(test_decorator, 'testValue', True) # Add this attribute to the returned function for testing\n return func(*args, **kwargs)\n return test_decorator\n\n@mock_s3\ndef testRegisterToClient():\n\n \"\"\"\n Test registering a decorator to a single boto3 session\n \"\"\"\n\n # Create a boto3 session\n s = boto3.session.Session()\n\n # Register the create_bucket() method to use our decorator for this session\n s.register_client_decorator('s3', 'create_bucket', myDecorator)\n\n # Now create our client as we normally would\n client1 = s.client('s3')\n\n # Now we can see that create_bucket() was decorated by testing the attribute we added\n client1.create_bucket(Bucket='foo')\n assert hasattr(client1.create_bucket, 'testValue')\n\n # We can also see that this only applies to calls made by the session we registered by creating a new session through boto3.client() and not registering a decorator\n client2 = boto3.client('s3')\n client2.create_bucket(Bucket='foo')\n\n # Now we can see that client.create_bucket() is not decorated\n assert not hasattr(client2.create_bucket, 'testValue')\n\n # Remove the decorator from the session\n s.unregister_client_decorator('s3', 'create_bucket')\n\n # Now create a new client on the same session we created at first\n client3 = s.client('s3')\n client3.create_bucket(Bucket='bar')\n\n # The session should no longer be decorating methods for new clients\n assert not hasattr(client3.create_bucket, 'testValue1')\n```\n\n#### View [more examples in the project documentation directory](https://github.com/QuiNovas/botoinator/tree/master/documentation/examples).\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/QuiNovas/botoinator", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "botoinator", "package_url": "https://pypi.org/project/botoinator/", "platform": "", "project_url": "https://pypi.org/project/botoinator/", "project_urls": { "Homepage": "https://github.com/QuiNovas/botoinator" }, "release_url": "https://pypi.org/project/botoinator/0.0.5/", "requires_dist": null, "requires_python": "", "summary": "A decoration mechanism for boto3 that allows automatic decoration of any and all boto3 clients and resources", "version": "0.0.5" }, "last_serial": 5721586, "releases": { "0.0.3": [ { "comment_text": "", "digests": { "md5": "3f3b1bf40906e271e35000b796c6ca2a", "sha256": "2ec322ec61bab7582988c234221622e63f0fa9f0640755761fc64b091767e00c" }, "downloads": -1, "filename": "botoinator-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3f3b1bf40906e271e35000b796c6ca2a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8544, "upload_time": "2019-08-21T20:07:27", "url": "https://files.pythonhosted.org/packages/c4/1f/46f8ae02d01c81c3c428fffc480be97ba11d14333f9aa6e0ffefd483c67e/botoinator-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c082270423e3d13fb81b1980539a8841", "sha256": "6e0b5aa42526b0079073d062d92a9a2e14b91c1522ea73653ce0b8a57622b741" }, "downloads": -1, "filename": "botoinator-0.0.3.tar.gz", "has_sig": false, "md5_digest": "c082270423e3d13fb81b1980539a8841", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4182, "upload_time": "2019-08-21T20:07:28", "url": "https://files.pythonhosted.org/packages/1f/86/cd20e49093f697d922b7ee74934e6ee9e3914b94f8ee6cb0713f8eb4c191/botoinator-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "62dcb88d99a33202d526d643ab055a8d", "sha256": "32161f0b1300dc3a9ac7ff555fb055ec8c35ff8d44253356e40db0b1c30ca0e0" }, "downloads": -1, "filename": "botoinator-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "62dcb88d99a33202d526d643ab055a8d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8548, "upload_time": "2019-08-23T16:05:41", "url": "https://files.pythonhosted.org/packages/b6/ee/08af2ad002ecf94e1c2bcc0dde5033c1e87418bcdceedd7b3ae6242e6660/botoinator-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e8b4b7c25356f37b9d0b7f02f5bb8d82", "sha256": "b96a2617728cffe7987db9cad7bd68c63e4998d06bcebbf6d5a868adaf974eaf" }, "downloads": -1, "filename": "botoinator-0.0.4.tar.gz", "has_sig": false, "md5_digest": "e8b4b7c25356f37b9d0b7f02f5bb8d82", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4183, "upload_time": "2019-08-23T16:05:42", "url": "https://files.pythonhosted.org/packages/85/7f/e99f3cb1c697afba14cc4e07950ae1dc6f1b91dbb5ca4f4ae7d13b3b9923/botoinator-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "b3783517098e84b0c2c2ff3cd0b09051", "sha256": "eca57f237cc183a9e5ca01c76a28ce3a72531aa3cdfd8bd02a52ca61f39a2f95" }, "downloads": -1, "filename": "botoinator-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b3783517098e84b0c2c2ff3cd0b09051", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8542, "upload_time": "2019-08-23T16:26:36", "url": "https://files.pythonhosted.org/packages/e4/18/de7a28f646c9e087e9757dc6cf87898920daeadbc4f24024f40ddd531640/botoinator-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fd13823035d05d67c2d19216dd4c4687", "sha256": "d38cee30199a01570662d3a9c54aaf540995e47de684c102c7acce5ad595b16d" }, "downloads": -1, "filename": "botoinator-0.0.5.tar.gz", "has_sig": false, "md5_digest": "fd13823035d05d67c2d19216dd4c4687", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4173, "upload_time": "2019-08-23T16:26:37", "url": "https://files.pythonhosted.org/packages/b4/cd/c731982204b85e7906e75f0a02ebdd6b3d4b19c90638c2c0c6e9b80fea13/botoinator-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b3783517098e84b0c2c2ff3cd0b09051", "sha256": "eca57f237cc183a9e5ca01c76a28ce3a72531aa3cdfd8bd02a52ca61f39a2f95" }, "downloads": -1, "filename": "botoinator-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b3783517098e84b0c2c2ff3cd0b09051", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8542, "upload_time": "2019-08-23T16:26:36", "url": "https://files.pythonhosted.org/packages/e4/18/de7a28f646c9e087e9757dc6cf87898920daeadbc4f24024f40ddd531640/botoinator-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fd13823035d05d67c2d19216dd4c4687", "sha256": "d38cee30199a01570662d3a9c54aaf540995e47de684c102c7acce5ad595b16d" }, "downloads": -1, "filename": "botoinator-0.0.5.tar.gz", "has_sig": false, "md5_digest": "fd13823035d05d67c2d19216dd4c4687", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4173, "upload_time": "2019-08-23T16:26:37", "url": "https://files.pythonhosted.org/packages/b4/cd/c731982204b85e7906e75f0a02ebdd6b3d4b19c90638c2c0c6e9b80fea13/botoinator-0.0.5.tar.gz" } ] }