{"action":"created","comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/comments/34843581","id":34843581,"diff_hunk":"@@ -0,0 +1,421 @@\n+#!/usr/bin/python\n+#\n+# This is a free software: you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation, either version 3 of the License, or\n+# (at your option) any later version.\n+#\n+# This Ansible library is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with this library.  If not, see <http://www.gnu.org/licenses/>.\n+\n+DOCUMENTATION = '''\n+---\n+module: s3_lifecycle\n+short_description: Manage s3 bucket lifecycle rules in AWS\n+description:\n+    - Manage s3 bucket lifecycle rules in AWS\n+version_added: \"2.0\"\n+author: Rob White (@wimnat)\n+notes:\n+  - If specifying expiration time as days then transition time must also be specified in days\n+  - If specifying expiration time as a date then transition time must also be specified as a date\n+requirements:\n+  - python-dateutil\n+options:\n+  name:\n+    description:\n+      - \"Name of the s3 bucket\"\n+    required: true\n+  expiration_date:\n+    description:\n+      - \"Indicates the lifetime of the objects that are subject to the rule by the date they will expire. The value must be ISO-8601 format, the time must be midnight and a GMT timezone must be specified.\"\n+    required: false\n+    default: null  \n+  expiration_days:\n+    description:\n+      - \"Indicates the lifetime, in days, of the objects that are subject to the rule. The value must be a non-zero positive integer.\"\n+    required: false\n+    default: null\n+  prefix:\n+    description:\n+      - \"Prefix identifying one or more objects to which the rule applies. If no prefix is specified, the rule will apply to the whole bucket.\"\n+      required: false\n+      default: null\n+  region:\n+    description:\n+     - \"AWS region to create the bucket in. If not set then the value of the AWS_REGION and EC2_REGION environment variables are checked, followed by the aws_region and ec2_region settings in the Boto config file.  If none of those are set the region defaults to the S3 Location: US Standard.\"\n+    required: false\n+    default: null\n+  rule_id:\n+    description:\n+      - \"Unique identifier for the rule. The value cannot be longer than 255 characters. A unique value for the rule will be generated if no value is provided.\"\n+      required: false\n+      default: null\n+  state:\n+    description:\n+      - \"Create or remove the lifecycle rule\"\n+    required: false\n+    default: present\n+    choices: [ 'present', 'absent' ]\n+  status:\n+    description:\n+      - \"If 'enabled', the rule is currently being applied. If 'disabled', the rule is not currently being applied.\"\n+    required: false\n+    default: enabled\n+    choices: [ 'enabled', 'disabled' ]\n+  storage_class:\n+    description:\n+      - \"The storage class to transition to. Currently there is only one valid value - 'glacier'.\"\n+    required: false\n+    default: glacier\n+    choices: [ 'glacier' ]\n+  transition_date:\n+    description:\n+      - \"Indicates the lifetime of the objects that are subject to the rule by the date they will transition to a different storage class. The value must be ISO-8601 format, the time must be midnight and a GMT timezone must be specified. If transition_days is not specified, this parameter is required.\"\n+    required: false\n+    default: null\n+  transition_days:\n+    description:\n+      - \"Indicates when, in days, an object transitions to a different storage class. If transition_date is not specified, this parameter is required.\"\n+    required: false\n+    default: null\n+\n+extends_documentation_fragment: aws\n+'''\n+\n+EXAMPLES = '''\n+# Note: These examples do not set authentication details, see the AWS Guide for details.\n+\n+# Configure a lifecycle rule on a bucket to expire (delete) items with a prefix of /logs/ after 30 days\n+- s3_lifecycle:\n+    name: mybucket\n+    expiration_days: 30\n+    prefix: /logs/\n+    status: enabled\n+    state: present\n+    \n+# Configure a lifecycle rule to transition all items with a prefix of /logs/ to glacier after 7 days and then delete after 90 days\n+- s3_lifecycle:\n+    name: mybucket\n+    transition_days: 7\n+    expiration_days: 90\n+    prefix: /logs/\n+    status: enabled\n+    state: present\n+    \n+# Configure a lifecycle rule to transition all items with a prefix of /logs/ to glacier on 31 Dec 2020 and then delete on 31 Dec 2030. Note that midnight GMT must be specified.\n+# Be sure to quote your date strings\n+- s3_lifecycle:\n+    name: mybucket\n+    transition_date: \"2020-12-30T00:00:00.000Z\"\n+    expiration_date: \"2030-12-30T00:00:00.000Z\"\n+    prefix: /logs/\n+    status: enabled\n+    state: present\n+    \n+# Disable the rule created above\n+- s3_lifecycle:\n+    name: mybucket\n+    prefix: /logs/\n+    status: disabled\n+    state: present\n+    \n+# Delete the lifecycle rule created above\n+- s3_lifecycle:\n+    name: mybucket\n+    prefix: /logs/\n+    state: absent\n+    \n+'''\n+\n+import xml.etree.ElementTree as ET\n+import copy\n+import datetime\n+\n+try:\n+    import dateutil.parser\n+    HAS_DATEUTIL = True\n+except ImportError:\n+    HAS_DATEUTIL = False\n+\n+try:\n+    import boto.ec2\n+    from boto.s3.connection import OrdinaryCallingFormat","path":"cloud/amazon/s3_lifecycle.py","position":148,"original_position":148,"commit_id":"b1c0f412e8248e9aafc87684019d7fba92f9e9ec","original_commit_id":"b1c0f412e8248e9aafc87684019d7fba92f9e9ec","user":{"login":"rickmendes","id":892350,"avatar_url":"https://avatars.githubusercontent.com/u/892350?v=3","gravatar_id":"","url":"https://api.github.com/users/rickmendes","html_url":"https://github.com/rickmendes","followers_url":"https://api.github.com/users/rickmendes/followers","following_url":"https://api.github.com/users/rickmendes/following{/other_user}","gists_url":"https://api.github.com/users/rickmendes/gists{/gist_id}","starred_url":"https://api.github.com/users/rickmendes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickmendes/subscriptions","organizations_url":"https://api.github.com/users/rickmendes/orgs","repos_url":"https://api.github.com/users/rickmendes/repos","events_url":"https://api.github.com/users/rickmendes/events{/privacy}","received_events_url":"https://api.github.com/users/rickmendes/received_events","type":"User","site_admin":false},"body":"Testing with v1, I had to change this import to:\r\n\r\n```python\r\nfrom boto.s3.connection import OrdinaryCallingFormat, Location\r\n```\r\nI haven't been able to test with v2 because the latest v2 hacking stuff is broken for me.","created_at":"2015-07-16T22:08:29Z","updated_at":"2015-07-16T22:08:29Z","html_url":"https://github.com/ansible/ansible-modules-extras/pull/718#discussion_r34843581","pull_request_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/718","_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/comments/34843581"},"html":{"href":"https://github.com/ansible/ansible-modules-extras/pull/718#discussion_r34843581"},"pull_request":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/718"}}},"pull_request":{"url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/718","id":40086263,"html_url":"https://github.com/ansible/ansible-modules-extras/pull/718","diff_url":"https://github.com/ansible/ansible-modules-extras/pull/718.diff","patch_url":"https://github.com/ansible/ansible-modules-extras/pull/718.patch","issue_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/718","number":718,"state":"open","locked":false,"title":"New module - s3_lifecycle","user":{"login":"wimnat","id":7425606,"avatar_url":"https://avatars.githubusercontent.com/u/7425606?v=3","gravatar_id":"","url":"https://api.github.com/users/wimnat","html_url":"https://github.com/wimnat","followers_url":"https://api.github.com/users/wimnat/followers","following_url":"https://api.github.com/users/wimnat/following{/other_user}","gists_url":"https://api.github.com/users/wimnat/gists{/gist_id}","starred_url":"https://api.github.com/users/wimnat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wimnat/subscriptions","organizations_url":"https://api.github.com/users/wimnat/orgs","repos_url":"https://api.github.com/users/wimnat/repos","events_url":"https://api.github.com/users/wimnat/events{/privacy}","received_events_url":"https://api.github.com/users/wimnat/received_events","type":"User","site_admin":false},"body":"New module complementing other s3_ modules.  Adds bucket lifecycle rule management functionality.","created_at":"2015-07-16T01:17:40Z","updated_at":"2015-07-16T22:08:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c501f90ce567240ae7c24ac43b41a95ded26dae1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/718/commits","review_comments_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/718/comments","review_comment_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/718/comments","statuses_url":"https://api.github.com/repos/ansible/ansible-modules-extras/statuses/b1c0f412e8248e9aafc87684019d7fba92f9e9ec","head":{"label":"wimnat:feature/s3_lifecycle","ref":"feature/s3_lifecycle","sha":"b1c0f412e8248e9aafc87684019d7fba92f9e9ec","user":{"login":"wimnat","id":7425606,"avatar_url":"https://avatars.githubusercontent.com/u/7425606?v=3","gravatar_id":"","url":"https://api.github.com/users/wimnat","html_url":"https://github.com/wimnat","followers_url":"https://api.github.com/users/wimnat/followers","following_url":"https://api.github.com/users/wimnat/following{/other_user}","gists_url":"https://api.github.com/users/wimnat/gists{/gist_id}","starred_url":"https://api.github.com/users/wimnat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wimnat/subscriptions","organizations_url":"https://api.github.com/users/wimnat/orgs","repos_url":"https://api.github.com/users/wimnat/repos","events_url":"https://api.github.com/users/wimnat/events{/privacy}","received_events_url":"https://api.github.com/users/wimnat/received_events","type":"User","site_admin":false},"repo":{"id":29625600,"name":"ansible-modules-extras","full_name":"wimnat/ansible-modules-extras","owner":{"login":"wimnat","id":7425606,"avatar_url":"https://avatars.githubusercontent.com/u/7425606?v=3","gravatar_id":"","url":"https://api.github.com/users/wimnat","html_url":"https://github.com/wimnat","followers_url":"https://api.github.com/users/wimnat/followers","following_url":"https://api.github.com/users/wimnat/following{/other_user}","gists_url":"https://api.github.com/users/wimnat/gists{/gist_id}","starred_url":"https://api.github.com/users/wimnat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wimnat/subscriptions","organizations_url":"https://api.github.com/users/wimnat/orgs","repos_url":"https://api.github.com/users/wimnat/repos","events_url":"https://api.github.com/users/wimnat/events{/privacy}","received_events_url":"https://api.github.com/users/wimnat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wimnat/ansible-modules-extras","description":"Ansible extra modules - these modules ship with ansible","fork":true,"url":"https://api.github.com/repos/wimnat/ansible-modules-extras","forks_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/forks","keys_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/teams","hooks_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/hooks","issue_events_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/issues/events{/number}","events_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/events","assignees_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/assignees{/user}","branches_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/branches{/branch}","tags_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/tags","blobs_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/git/refs{/sha}","trees_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/statuses/{sha}","languages_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/languages","stargazers_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/stargazers","contributors_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/contributors","subscribers_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/subscribers","subscription_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/subscription","commits_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/commits{/sha}","git_commits_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/git/commits{/sha}","comments_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/comments{/number}","issue_comment_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/issues/comments{/number}","contents_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/contents/{+path}","compare_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/merges","archive_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/downloads","issues_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/issues{/number}","pulls_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/pulls{/number}","milestones_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/milestones{/number}","notifications_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/labels{/name}","releases_url":"https://api.github.com/repos/wimnat/ansible-modules-extras/releases{/id}","created_at":"2015-01-21T22:58:36Z","updated_at":"2015-06-16T22:26:41Z","pushed_at":"2015-07-16T01:16:48Z","git_url":"git://github.com/wimnat/ansible-modules-extras.git","ssh_url":"git@github.com:wimnat/ansible-modules-extras.git","clone_url":"https://github.com/wimnat/ansible-modules-extras.git","svn_url":"https://github.com/wimnat/ansible-modules-extras","homepage":"","size":6981,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"devel"}},"base":{"label":"ansible:devel","ref":"devel","sha":"ff2386faf49dd44964fac084ed7199ab4ea5f741","user":{"login":"ansible","id":1507452,"avatar_url":"https://avatars.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"repo":{"id":24474138,"name":"ansible-modules-extras","full_name":"ansible/ansible-modules-extras","owner":{"login":"ansible","id":1507452,"avatar_url":"https://avatars.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ansible/ansible-modules-extras","description":"Ansible extra modules - these modules ship with ansible","fork":false,"url":"https://api.github.com/repos/ansible/ansible-modules-extras","forks_url":"https://api.github.com/repos/ansible/ansible-modules-extras/forks","keys_url":"https://api.github.com/repos/ansible/ansible-modules-extras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ansible/ansible-modules-extras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ansible/ansible-modules-extras/teams","hooks_url":"https://api.github.com/repos/ansible/ansible-modules-extras/hooks","issue_events_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/events{/number}","events_url":"https://api.github.com/repos/ansible/ansible-modules-extras/events","assignees_url":"https://api.github.com/repos/ansible/ansible-modules-extras/assignees{/user}","branches_url":"https://api.github.com/repos/ansible/ansible-modules-extras/branches{/branch}","tags_url":"https://api.github.com/repos/ansible/ansible-modules-extras/tags","blobs_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/refs{/sha}","trees_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ansible/ansible-modules-extras/statuses/{sha}","languages_url":"https://api.github.com/repos/ansible/ansible-modules-extras/languages","stargazers_url":"https://api.github.com/repos/ansible/ansible-modules-extras/stargazers","contributors_url":"https://api.github.com/repos/ansible/ansible-modules-extras/contributors","subscribers_url":"https://api.github.com/repos/ansible/ansible-modules-extras/subscribers","subscription_url":"https://api.github.com/repos/ansible/ansible-modules-extras/subscription","commits_url":"https://api.github.com/repos/ansible/ansible-modules-extras/commits{/sha}","git_commits_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/commits{/sha}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-extras/comments{/number}","issue_comment_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/comments{/number}","contents_url":"https://api.github.com/repos/ansible/ansible-modules-extras/contents/{+path}","compare_url":"https://api.github.com/repos/ansible/ansible-modules-extras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ansible/ansible-modules-extras/merges","archive_url":"https://api.github.com/repos/ansible/ansible-modules-extras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ansible/ansible-modules-extras/downloads","issues_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues{/number}","pulls_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls{/number}","milestones_url":"https://api.github.com/repos/ansible/ansible-modules-extras/milestones{/number}","notifications_url":"https://api.github.com/repos/ansible/ansible-modules-extras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ansible/ansible-modules-extras/labels{/name}","releases_url":"https://api.github.com/repos/ansible/ansible-modules-extras/releases{/id}","created_at":"2014-09-25T20:28:42Z","updated_at":"2015-07-15T00:43:20Z","pushed_at":"2015-07-16T22:02:20Z","git_url":"git://github.com/ansible/ansible-modules-extras.git","ssh_url":"git@github.com:ansible/ansible-modules-extras.git","clone_url":"https://github.com/ansible/ansible-modules-extras.git","svn_url":"https://github.com/ansible/ansible-modules-extras","homepage":"","size":25251,"stargazers_count":260,"watchers_count":260,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":544,"mirror_url":null,"open_issues_count":207,"forks":544,"open_issues":207,"watchers":260,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/718"},"html":{"href":"https://github.com/ansible/ansible-modules-extras/pull/718"},"issue":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/718"},"comments":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/718/comments"},"review_comments":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/718/comments"},"review_comment":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/718/commits"},"statuses":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/statuses/b1c0f412e8248e9aafc87684019d7fba92f9e9ec"}}}}