We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
aws.cloudtrail - tag filter
Objective: I want to write a policy to identify all cloud trails with missing tags. Currently it does not support this.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `c7n/resources/cloudtrail.py`
Content:
```
1 # Copyright 2017-2019 Capital One Services, LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from __future__ import absolute_import, division, print_function, unicode_literals
15 
16 import logging
17 
18 from c7n.actions import Action, BaseAction
19 from c7n.exceptions import PolicyValidationError
20 from c7n.filters import ValueFilter, Filter
21 from c7n.manager import resources
22 from c7n.query import QueryResourceManager, TypeInfo
23 from c7n.utils import local_session, type_schema
24 
25 from .aws import shape_validate, Arn
26 
27 log = logging.getLogger('c7n.resources.cloudtrail')
28 
29 
30 @resources.register('cloudtrail')
31 class CloudTrail(QueryResourceManager):
32 
33     class resource_type(TypeInfo):
34         service = 'cloudtrail'
35         enum_spec = ('describe_trails', 'trailList', None)
36         filter_name = 'trailNameList'
37         filter_type = 'list'
38         arn = id = 'TrailARN'
39         name = 'Name'
40         config_type = "AWS::CloudTrail::Trail"
41 
42 
43 @CloudTrail.filter_registry.register('is-shadow')
44 class IsShadow(Filter):
45     """Identify shadow trails (secondary copies), shadow trails
46     can't be modified directly, the origin trail needs to be modified.
47 
48     Shadow trails are created for multi-region trails as well for
49     organizational trails.
50     """
51     schema = type_schema('is-shadow', state={'type': 'boolean'})
52     permissions = ('cloudtrail:DescribeTrails',)
53     embedded = False
54 
55     def process(self, resources, event=None):
56         rcount = len(resources)
57         trails = [t for t in resources if (self.is_shadow(t) == self.data.get('state', True))]
58         if len(trails) != rcount and self.embedded:
59             self.log.info("implicitly filtering shadow trails %d -> %d",
60                      rcount, len(trails))
61         return trails
62 
63     def is_shadow(self, t):
64         if t.get('IsOrganizationTrail') and self.manager.config.account_id not in t['TrailARN']:
65             return True
66         if t.get('IsMultiRegionTrail') and t['HomeRegion'] != self.manager.config.region:
67             return True
68         return False
69 
70 
71 @CloudTrail.filter_registry.register('status')
72 class Status(ValueFilter):
73     """Filter a cloudtrail by its status.
74 
75     :Example:
76 
77     .. code-block:: yaml
78 
79         policies:
80           - name: cloudtrail-check-status
81             resource: aws.cloudtrail
82             filters:
83             - type: status
84               key: IsLogging
85               value: False
86     """
87 
88     schema = type_schema('status', rinherit=ValueFilter.schema)
89     schema_alias = False
90     permissions = ('cloudtrail:GetTrailStatus',)
91     annotation_key = 'c7n:TrailStatus'
92 
93     def process(self, resources, event=None):
94         for r in resources:
95             region = self.manager.config.region
96             trail_arn = Arn.parse(r['TrailARN'])
97 
98             if (r.get('IsOrganizationTrail') and
99                     self.manager.config.account_id != trail_arn.account_id):
100                 continue
101             if r.get('HomeRegion') and r['HomeRegion'] != region:
102                 region = trail_arn.region
103             if self.annotation_key in r:
104                 continue
105             client = local_session(self.manager.session_factory).client(
106                 'cloudtrail', region_name=region)
107             status = client.get_trail_status(Name=r['Name'])
108             status.pop('ResponseMetadata')
109             r[self.annotation_key] = status
110 
111         return super(Status, self).process(resources)
112 
113     def __call__(self, r):
114         return self.match(r['c7n:TrailStatus'])
115 
116 
117 @CloudTrail.action_registry.register('update-trail')
118 class UpdateTrail(Action):
119     """Update trail attributes.
120 
121     :Example:
122 
123     .. code-block:: yaml
124 
125        policies:
126          - name: cloudtrail-set-log
127            resource: aws.cloudtrail
128            filters:
129             - or:
130               - KmsKeyId: empty
131               - LogFileValidationEnabled: false
132            actions:
133             - type: update-trail
134               attributes:
135                 KmsKeyId: arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef
136                 EnableLogFileValidation: true
137     """
138     schema = type_schema(
139         'update-trail',
140         attributes={'type': 'object'},
141         required=('attributes',))
142     shape = 'UpdateTrailRequest'
143     permissions = ('cloudtrail:UpdateTrail',)
144 
145     def validate(self):
146         attrs = dict(self.data['attributes'])
147         if 'Name' in attrs:
148             raise PolicyValidationError(
149                 "Can't include Name in update-trail action")
150         attrs['Name'] = 'PolicyValidation'
151         return shape_validate(
152             attrs,
153             self.shape,
154             self.manager.resource_type.service)
155 
156     def process(self, resources):
157         client = local_session(self.manager.session_factory).client('cloudtrail')
158         shadow_check = IsShadow({'state': False}, self.manager)
159         shadow_check.embedded = True
160         resources = shadow_check.process(resources)
161 
162         for r in resources:
163             client.update_trail(
164                 Name=r['Name'],
165                 **self.data['attributes'])
166 
167 
168 @CloudTrail.action_registry.register('set-logging')
169 class SetLogging(Action):
170     """Set the logging state of a trail
171 
172     :Example:
173 
174     .. code-block:: yaml
175 
176       policies:
177         - name: cloudtrail-set-active
178           resource: aws.cloudtrail
179           filters:
180            - type: status
181              key: IsLogging
182              value: False
183           actions:
184            - type: set-logging
185              enabled: True
186     """
187     schema = type_schema(
188         'set-logging', enabled={'type': 'boolean'})
189 
190     def get_permissions(self):
191         enable = self.data.get('enabled', True)
192         if enable is True:
193             return ('cloudtrail:StartLogging',)
194         else:
195             return ('cloudtrail:StopLogging',)
196 
197     def process(self, resources):
198         client = local_session(self.manager.session_factory).client('cloudtrail')
199         shadow_check = IsShadow({'state': False}, self.manager)
200         shadow_check.embedded = True
201         resources = shadow_check.process(resources)
202         enable = self.data.get('enabled', True)
203 
204         for r in resources:
205             if enable:
206                 client.start_logging(Name=r['Name'])
207             else:
208                 client.stop_logging(Name=r['Name'])
209 
210 
211 @CloudTrail.action_registry.register('delete')
212 class DeleteTrail(BaseAction):
213     """ Delete a cloud trail
214 
215     :example:
216 
217     .. code-block:: yaml
218 
219       policies:
220         - name: delete-cloudtrail
221           resource: aws.cloudtrail
222           filters:
223            - type: value
224              key: Name
225              value: delete-me
226              op: eq
227           actions:
228            - type: delete
229     """
230 
231     schema = type_schema('delete')
232     permissions = ('cloudtrail:DeleteTrail',)
233 
234     def process(self, resources):
235         client = local_session(self.manager.session_factory).client('cloudtrail')
236         shadow_check = IsShadow({'state': False}, self.manager)
237         shadow_check.embedded = True
238         resources = shadow_check.process(resources)
239         for r in resources:
240             try:
241                 client.delete_trail(Name=r['Name'])
242             except client.exceptions.TrailNotFoundException:
243                 continue
244
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/c7n/resources/cloudtrail.py b/c7n/resources/cloudtrail.py
--- a/c7n/resources/cloudtrail.py
+++ b/c7n/resources/cloudtrail.py
@@ -19,7 +19,8 @@
 from c7n.exceptions import PolicyValidationError
 from c7n.filters import ValueFilter, Filter
 from c7n.manager import resources
-from c7n.query import QueryResourceManager, TypeInfo
+from c7n.tags import universal_augment
+from c7n.query import DescribeSource, QueryResourceManager, TypeInfo
 from c7n.utils import local_session, type_schema
 
 from .aws import shape_validate, Arn
@@ -38,6 +39,18 @@
         arn = id = 'TrailARN'
         name = 'Name'
         config_type = "AWS::CloudTrail::Trail"
+        universal_taggable = object()
+
+    def get_source(self, source_type):
+        if source_type == 'describe':
+            return DescribeTrail(self)
+        return super(CloudTrail, self).get_source(source_type)
+
+
+class DescribeTrail(DescribeSource):
+
+    def augment(self, resources):
+        return universal_augment(self.manager, resources)
 
 
 @CloudTrail.filter_registry.register('is-shadow')

{"golden_diff": "diff --git a/c7n/resources/cloudtrail.py b/c7n/resources/cloudtrail.py\n--- a/c7n/resources/cloudtrail.py\n+++ b/c7n/resources/cloudtrail.py\n@@ -19,7 +19,8 @@\n from c7n.exceptions import PolicyValidationError\n from c7n.filters import ValueFilter, Filter\n from c7n.manager import resources\n-from c7n.query import QueryResourceManager, TypeInfo\n+from c7n.tags import universal_augment\n+from c7n.query import DescribeSource, QueryResourceManager, TypeInfo\n from c7n.utils import local_session, type_schema\n \n from .aws import shape_validate, Arn\n@@ -38,6 +39,18 @@\n         arn = id = 'TrailARN'\n         name = 'Name'\n         config_type = \"AWS::CloudTrail::Trail\"\n+        universal_taggable = object()\n+\n+    def get_source(self, source_type):\n+        if source_type == 'describe':\n+            return DescribeTrail(self)\n+        return super(CloudTrail, self).get_source(source_type)\n+\n+\n+class DescribeTrail(DescribeSource):\n+\n+    def augment(self, resources):\n+        return universal_augment(self.manager, resources)\n \n \n @CloudTrail.filter_registry.register('is-shadow')\n", "issue": "aws.cloudtrail - tag filter\nObjective: I want to write a policy to identify all cloud trails with missing tags. Currently it does not support this.\n", "before_files": [{"content": "# Copyright 2017-2019 Capital One Services, LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport logging\n\nfrom c7n.actions import Action, BaseAction\nfrom c7n.exceptions import PolicyValidationError\nfrom c7n.filters import ValueFilter, Filter\nfrom c7n.manager import resources\nfrom c7n.query import QueryResourceManager, TypeInfo\nfrom c7n.utils import local_session, type_schema\n\nfrom .aws import shape_validate, Arn\n\nlog = logging.getLogger('c7n.resources.cloudtrail')\n\n\n@resources.register('cloudtrail')\nclass CloudTrail(QueryResourceManager):\n\n    class resource_type(TypeInfo):\n        service = 'cloudtrail'\n        enum_spec = ('describe_trails', 'trailList', None)\n        filter_name = 'trailNameList'\n        filter_type = 'list'\n        arn = id = 'TrailARN'\n        name = 'Name'\n        config_type = \"AWS::CloudTrail::Trail\"\n\n\n@CloudTrail.filter_registry.register('is-shadow')\nclass IsShadow(Filter):\n    \"\"\"Identify shadow trails (secondary copies), shadow trails\n    can't be modified directly, the origin trail needs to be modified.\n\n    Shadow trails are created for multi-region trails as well for\n    organizational trails.\n    \"\"\"\n    schema = type_schema('is-shadow', state={'type': 'boolean'})\n    permissions = ('cloudtrail:DescribeTrails',)\n    embedded = False\n\n    def process(self, resources, event=None):\n        rcount = len(resources)\n        trails = [t for t in resources if (self.is_shadow(t) == self.data.get('state', True))]\n        if len(trails) != rcount and self.embedded:\n            self.log.info(\"implicitly filtering shadow trails %d -> %d\",\n                     rcount, len(trails))\n        return trails\n\n    def is_shadow(self, t):\n        if t.get('IsOrganizationTrail') and self.manager.config.account_id not in t['TrailARN']:\n            return True\n        if t.get('IsMultiRegionTrail') and t['HomeRegion'] != self.manager.config.region:\n            return True\n        return False\n\n\n@CloudTrail.filter_registry.register('status')\nclass Status(ValueFilter):\n    \"\"\"Filter a cloudtrail by its status.\n\n    :Example:\n\n    .. code-block:: yaml\n\n        policies:\n          - name: cloudtrail-check-status\n            resource: aws.cloudtrail\n            filters:\n            - type: status\n              key: IsLogging\n              value: False\n    \"\"\"\n\n    schema = type_schema('status', rinherit=ValueFilter.schema)\n    schema_alias = False\n    permissions = ('cloudtrail:GetTrailStatus',)\n    annotation_key = 'c7n:TrailStatus'\n\n    def process(self, resources, event=None):\n        for r in resources:\n            region = self.manager.config.region\n            trail_arn = Arn.parse(r['TrailARN'])\n\n            if (r.get('IsOrganizationTrail') and\n                    self.manager.config.account_id != trail_arn.account_id):\n                continue\n            if r.get('HomeRegion') and r['HomeRegion'] != region:\n                region = trail_arn.region\n            if self.annotation_key in r:\n                continue\n            client = local_session(self.manager.session_factory).client(\n                'cloudtrail', region_name=region)\n            status = client.get_trail_status(Name=r['Name'])\n            status.pop('ResponseMetadata')\n            r[self.annotation_key] = status\n\n        return super(Status, self).process(resources)\n\n    def __call__(self, r):\n        return self.match(r['c7n:TrailStatus'])\n\n\n@CloudTrail.action_registry.register('update-trail')\nclass UpdateTrail(Action):\n    \"\"\"Update trail attributes.\n\n    :Example:\n\n    .. code-block:: yaml\n\n       policies:\n         - name: cloudtrail-set-log\n           resource: aws.cloudtrail\n           filters:\n            - or:\n              - KmsKeyId: empty\n              - LogFileValidationEnabled: false\n           actions:\n            - type: update-trail\n              attributes:\n                KmsKeyId: arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef\n                EnableLogFileValidation: true\n    \"\"\"\n    schema = type_schema(\n        'update-trail',\n        attributes={'type': 'object'},\n        required=('attributes',))\n    shape = 'UpdateTrailRequest'\n    permissions = ('cloudtrail:UpdateTrail',)\n\n    def validate(self):\n        attrs = dict(self.data['attributes'])\n        if 'Name' in attrs:\n            raise PolicyValidationError(\n                \"Can't include Name in update-trail action\")\n        attrs['Name'] = 'PolicyValidation'\n        return shape_validate(\n            attrs,\n            self.shape,\n            self.manager.resource_type.service)\n\n    def process(self, resources):\n        client = local_session(self.manager.session_factory).client('cloudtrail')\n        shadow_check = IsShadow({'state': False}, self.manager)\n        shadow_check.embedded = True\n        resources = shadow_check.process(resources)\n\n        for r in resources:\n            client.update_trail(\n                Name=r['Name'],\n                **self.data['attributes'])\n\n\n@CloudTrail.action_registry.register('set-logging')\nclass SetLogging(Action):\n    \"\"\"Set the logging state of a trail\n\n    :Example:\n\n    .. code-block:: yaml\n\n      policies:\n        - name: cloudtrail-set-active\n          resource: aws.cloudtrail\n          filters:\n           - type: status\n             key: IsLogging\n             value: False\n          actions:\n           - type: set-logging\n             enabled: True\n    \"\"\"\n    schema = type_schema(\n        'set-logging', enabled={'type': 'boolean'})\n\n    def get_permissions(self):\n        enable = self.data.get('enabled', True)\n        if enable is True:\n            return ('cloudtrail:StartLogging',)\n        else:\n            return ('cloudtrail:StopLogging',)\n\n    def process(self, resources):\n        client = local_session(self.manager.session_factory).client('cloudtrail')\n        shadow_check = IsShadow({'state': False}, self.manager)\n        shadow_check.embedded = True\n        resources = shadow_check.process(resources)\n        enable = self.data.get('enabled', True)\n\n        for r in resources:\n            if enable:\n                client.start_logging(Name=r['Name'])\n            else:\n                client.stop_logging(Name=r['Name'])\n\n\n@CloudTrail.action_registry.register('delete')\nclass DeleteTrail(BaseAction):\n    \"\"\" Delete a cloud trail\n\n    :example:\n\n    .. code-block:: yaml\n\n      policies:\n        - name: delete-cloudtrail\n          resource: aws.cloudtrail\n          filters:\n           - type: value\n             key: Name\n             value: delete-me\n             op: eq\n          actions:\n           - type: delete\n    \"\"\"\n\n    schema = type_schema('delete')\n    permissions = ('cloudtrail:DeleteTrail',)\n\n    def process(self, resources):\n        client = local_session(self.manager.session_factory).client('cloudtrail')\n        shadow_check = IsShadow({'state': False}, self.manager)\n        shadow_check.embedded = True\n        resources = shadow_check.process(resources)\n        for r in resources:\n            try:\n                client.delete_trail(Name=r['Name'])\n            except client.exceptions.TrailNotFoundException:\n                continue\n", "path": "c7n/resources/cloudtrail.py"}], "after_files": [{"content": "# Copyright 2017-2019 Capital One Services, LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport logging\n\nfrom c7n.actions import Action, BaseAction\nfrom c7n.exceptions import PolicyValidationError\nfrom c7n.filters import ValueFilter, Filter\nfrom c7n.manager import resources\nfrom c7n.tags import universal_augment\nfrom c7n.query import DescribeSource, QueryResourceManager, TypeInfo\nfrom c7n.utils import local_session, type_schema\n\nfrom .aws import shape_validate, Arn\n\nlog = logging.getLogger('c7n.resources.cloudtrail')\n\n\n@resources.register('cloudtrail')\nclass CloudTrail(QueryResourceManager):\n\n    class resource_type(TypeInfo):\n        service = 'cloudtrail'\n        enum_spec = ('describe_trails', 'trailList', None)\n        filter_name = 'trailNameList'\n        filter_type = 'list'\n        arn = id = 'TrailARN'\n        name = 'Name'\n        config_type = \"AWS::CloudTrail::Trail\"\n        universal_taggable = object()\n\n    def get_source(self, source_type):\n        if source_type == 'describe':\n            return DescribeTrail(self)\n        return super(CloudTrail, self).get_source(source_type)\n\n\nclass DescribeTrail(DescribeSource):\n\n    def augment(self, resources):\n        return universal_augment(self.manager, resources)\n\n\n@CloudTrail.filter_registry.register('is-shadow')\nclass IsShadow(Filter):\n    \"\"\"Identify shadow trails (secondary copies), shadow trails\n    can't be modified directly, the origin trail needs to be modified.\n\n    Shadow trails are created for multi-region trails as well for\n    organizational trails.\n    \"\"\"\n    schema = type_schema('is-shadow', state={'type': 'boolean'})\n    permissions = ('cloudtrail:DescribeTrails',)\n    embedded = False\n\n    def process(self, resources, event=None):\n        rcount = len(resources)\n        trails = [t for t in resources if (self.is_shadow(t) == self.data.get('state', True))]\n        if len(trails) != rcount and self.embedded:\n            self.log.info(\"implicitly filtering shadow trails %d -> %d\",\n                     rcount, len(trails))\n        return trails\n\n    def is_shadow(self, t):\n        if t.get('IsOrganizationTrail') and self.manager.config.account_id not in t['TrailARN']:\n            return True\n        if t.get('IsMultiRegionTrail') and t['HomeRegion'] != self.manager.config.region:\n            return True\n        return False\n\n\n@CloudTrail.filter_registry.register('status')\nclass Status(ValueFilter):\n    \"\"\"Filter a cloudtrail by its status.\n\n    :Example:\n\n    .. code-block:: yaml\n\n        policies:\n          - name: cloudtrail-check-status\n            resource: aws.cloudtrail\n            filters:\n            - type: status\n              key: IsLogging\n              value: False\n    \"\"\"\n\n    schema = type_schema('status', rinherit=ValueFilter.schema)\n    schema_alias = False\n    permissions = ('cloudtrail:GetTrailStatus',)\n    annotation_key = 'c7n:TrailStatus'\n\n    def process(self, resources, event=None):\n        for r in resources:\n            region = self.manager.config.region\n            trail_arn = Arn.parse(r['TrailARN'])\n\n            if (r.get('IsOrganizationTrail') and\n                    self.manager.config.account_id != trail_arn.account_id):\n                continue\n            if r.get('HomeRegion') and r['HomeRegion'] != region:\n                region = trail_arn.region\n            if self.annotation_key in r:\n                continue\n            client = local_session(self.manager.session_factory).client(\n                'cloudtrail', region_name=region)\n            status = client.get_trail_status(Name=r['Name'])\n            status.pop('ResponseMetadata')\n            r[self.annotation_key] = status\n\n        return super(Status, self).process(resources)\n\n    def __call__(self, r):\n        return self.match(r['c7n:TrailStatus'])\n\n\n@CloudTrail.action_registry.register('update-trail')\nclass UpdateTrail(Action):\n    \"\"\"Update trail attributes.\n\n    :Example:\n\n    .. code-block:: yaml\n\n       policies:\n         - name: cloudtrail-set-log\n           resource: aws.cloudtrail\n           filters:\n            - or:\n              - KmsKeyId: empty\n              - LogFileValidationEnabled: false\n           actions:\n            - type: update-trail\n              attributes:\n                KmsKeyId: arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef\n                EnableLogFileValidation: true\n    \"\"\"\n    schema = type_schema(\n        'update-trail',\n        attributes={'type': 'object'},\n        required=('attributes',))\n    shape = 'UpdateTrailRequest'\n    permissions = ('cloudtrail:UpdateTrail',)\n\n    def validate(self):\n        attrs = dict(self.data['attributes'])\n        if 'Name' in attrs:\n            raise PolicyValidationError(\n                \"Can't include Name in update-trail action\")\n        attrs['Name'] = 'PolicyValidation'\n        return shape_validate(\n            attrs,\n            self.shape,\n            self.manager.resource_type.service)\n\n    def process(self, resources):\n        client = local_session(self.manager.session_factory).client('cloudtrail')\n        shadow_check = IsShadow({'state': False}, self.manager)\n        shadow_check.embedded = True\n        resources = shadow_check.process(resources)\n\n        for r in resources:\n            client.update_trail(\n                Name=r['Name'],\n                **self.data['attributes'])\n\n\n@CloudTrail.action_registry.register('set-logging')\nclass SetLogging(Action):\n    \"\"\"Set the logging state of a trail\n\n    :Example:\n\n    .. code-block:: yaml\n\n      policies:\n        - name: cloudtrail-set-active\n          resource: aws.cloudtrail\n          filters:\n           - type: status\n             key: IsLogging\n             value: False\n          actions:\n           - type: set-logging\n             enabled: True\n    \"\"\"\n    schema = type_schema(\n        'set-logging', enabled={'type': 'boolean'})\n\n    def get_permissions(self):\n        enable = self.data.get('enabled', True)\n        if enable is True:\n            return ('cloudtrail:StartLogging',)\n        else:\n            return ('cloudtrail:StopLogging',)\n\n    def process(self, resources):\n        client = local_session(self.manager.session_factory).client('cloudtrail')\n        shadow_check = IsShadow({'state': False}, self.manager)\n        shadow_check.embedded = True\n        resources = shadow_check.process(resources)\n        enable = self.data.get('enabled', True)\n\n        for r in resources:\n            if enable:\n                client.start_logging(Name=r['Name'])\n            else:\n                client.stop_logging(Name=r['Name'])\n\n\n@CloudTrail.action_registry.register('delete')\nclass DeleteTrail(BaseAction):\n    \"\"\" Delete a cloud trail\n\n    :example:\n\n    .. code-block:: yaml\n\n      policies:\n        - name: delete-cloudtrail\n          resource: aws.cloudtrail\n          filters:\n           - type: value\n             key: Name\n             value: delete-me\n             op: eq\n          actions:\n           - type: delete\n    \"\"\"\n\n    schema = type_schema('delete')\n    permissions = ('cloudtrail:DeleteTrail',)\n\n    def process(self, resources):\n        client = local_session(self.manager.session_factory).client('cloudtrail')\n        shadow_check = IsShadow({'state': False}, self.manager)\n        shadow_check.embedded = True\n        resources = shadow_check.process(resources)\n        for r in resources:\n            try:\n                client.delete_trail(Name=r['Name'])\n            except client.exceptions.TrailNotFoundException:\n                continue\n", "path": "c7n/resources/cloudtrail.py"}]}