manheim_c7n_tools.notifyonly module

class manheim_c7n_tools.notifyonly.NotifyOnlyPolicy(policy: dict)[source]

Bases: object

This class converts a c7n policy to a “notify only” policy. See Notify-Only Option for Policies for details.

IMPORTANT: When making changes to this class, be SURE to update Notify-Only Option for Policies in the documentation.

_fix_actions(original: List[T]) → List[T][source]

Given a list of actions from a policy, return a new list of notify-only actions.

  • notify actions will be included unmodified
  • mark / tag actions will be passed through _fix_tag_action() and the result included
  • mark-for-op actions will be passed through _fix_mark_for_op_action() and the result included
  • remove-tag / unmark / untag actions will be passed through _fix_untag_action() and the result included
  • all other actions will be REMOVED
Parameters:original (list) – original policy actions list
Returns:new list of actions
Return type:list
_fix_comment(comment: str) → str[source]

Convert a policy comment/comments/description to a notify only version, by prefixing it with the string “NOTIFY ONLY: “.

Parameters:comment (str) – the original policy comment
Returns:the modified comment
Return type:str
_fix_filters(filters: List[T]) → List[T][source]

Given a list of filters from a policy, update them for any tagging changes.

Parameters:filters (list) – filters from policy, or a subset thereof
Returns:fixed filters
Return type:list
_fix_mark_for_op_action(item: dict) → dict[source]

Fix a mark-for-op action for notify-only operation.

The string notify-only will be appended to the tag name used.

Parameters:item (dict) – the original action
Returns:the modified action
Return type:dict
_fix_notify_action(item: dict) → dict[source]

Fix a notify action for notify-only operation.

If the violation_desc key is present, its value will be prefixed with NOTIFY ONLY: ``. If the ``action_desc key is present, its value will be prefixed with the string in the future (currently notify-only).

Parameters:item (dict) – the original action
Returns:the modified action
Return type:dict
_fix_tag_action(item: dict) → dict[source]

Fix a tag / mark action for notify-only operation.

The string -notify-only will be appended to the tag item, key item, and/or every item in the tags list.

If none of these values are set, the tag item will be set to the custodian DEFAULT_TAG, suffixed with -notify-only.

Parameters:item (dict) – the original action
Returns:the modified action
Return type:dict
_fix_tags(tags: List[str]) → List[str][source]

Convert a policy tags list to a notify only version, by appending a notify-only tag to the list.

Parameters:tags (list) – the original tags list
Returns:the modified list, with a notify-only tag appended
Return type:list
_fix_untag_action(item: dict) → dict[source]

Fix a remove-tag / unmark / untag action for notify-only operation.

All tag names in the tags list will have -notify-only appended.

Parameters:item (dict) – the original action
Returns:the modified action
Return type:dict
_process(policy: dict) → dict[source]

Return the given policy, converted to notify-only.

Parameters:policy (dict) – the original c7n policy
Returns:policy, modified for notify-only mode
Return type:dict
as_notify_only() → dict[source]

Return the policy, converted to a notify-only version.

Returns:converted policy
Return type:dict