mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #39969 from bodhi-space/infra4506
INFRA-4506 - add list_rules() function to boto_cloudwatch module
This commit is contained in:
commit
b77080587f
@ -209,6 +209,29 @@ def describe(Name,
|
||||
return {'error': __utils__['boto3.get_error'](e)}
|
||||
|
||||
|
||||
def list_rules(region=None, key=None, keyid=None, profile=None):
|
||||
'''
|
||||
List, with details, all Cloudwatch Event rules visible in the current scope.
|
||||
|
||||
CLI example::
|
||||
|
||||
salt myminion boto_cloudwatch_event.list_rules region=us-east-1
|
||||
'''
|
||||
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
|
||||
|
||||
try:
|
||||
ret = []
|
||||
NextToken = ''
|
||||
while NextToken is not None:
|
||||
args = {'NextToken': NextToken} if NextToken else {}
|
||||
r = conn.list_rules(**args)
|
||||
ret += r.get('Rules', [])
|
||||
NextToken = r.get('NextToken')
|
||||
return ret
|
||||
except ClientError as e:
|
||||
return {'error': __utils__['boto3.get_error'](e)}
|
||||
|
||||
|
||||
def list_targets(Rule,
|
||||
region=None, key=None, keyid=None, profile=None):
|
||||
'''
|
||||
|
@ -72,7 +72,7 @@ def __virtual__():
|
||||
return 'boto_cloudwatch_event' if 'boto_cloudwatch_event.exists' in __salt__ else False
|
||||
|
||||
|
||||
def present(name, Name,
|
||||
def present(name, Name=None,
|
||||
ScheduleExpression=None,
|
||||
EventPattern=None,
|
||||
Description=None,
|
||||
@ -87,7 +87,8 @@ def present(name, Name,
|
||||
The name of the state definition
|
||||
|
||||
Name
|
||||
Name of the event rule.
|
||||
Name of the event rule. Defaults to the value of the 'name' param if
|
||||
not provided.
|
||||
|
||||
ScheduleExpression
|
||||
The scheduling expression. For example, "cron(0 20 * * ? *)",
|
||||
@ -128,6 +129,8 @@ def present(name, Name,
|
||||
'changes': {}
|
||||
}
|
||||
|
||||
Name = Name if Name else name
|
||||
|
||||
if isinstance(Targets, six.string_types):
|
||||
Targets = json.loads(Targets)
|
||||
if Targets is None:
|
||||
@ -264,8 +267,7 @@ def present(name, Name,
|
||||
return ret
|
||||
|
||||
|
||||
def absent(name, Name,
|
||||
region=None, key=None, keyid=None, profile=None):
|
||||
def absent(name, Name=None, region=None, key=None, keyid=None, profile=None):
|
||||
'''
|
||||
Ensure CloudWatch event rule with passed properties is absent.
|
||||
|
||||
@ -273,7 +275,8 @@ def absent(name, Name,
|
||||
The name of the state definition.
|
||||
|
||||
Name
|
||||
Name of the event rule.
|
||||
Name of the event rule. Defaults to the value of the 'name' param if
|
||||
not provided.
|
||||
|
||||
region
|
||||
Region to connect to.
|
||||
@ -295,6 +298,8 @@ def absent(name, Name,
|
||||
'changes': {}
|
||||
}
|
||||
|
||||
Name = Name if Name else name
|
||||
|
||||
r = __salt__['boto_cloudwatch_event.exists'](Name,
|
||||
region=region, key=key, keyid=keyid, profile=profile)
|
||||
if 'error' in r:
|
||||
|
@ -268,7 +268,7 @@ def function_present(name, FunctionName, Runtime, Role, Handler, ZipFile=None,
|
||||
Environment, region, key, keyid,
|
||||
profile, RoleRetries)
|
||||
if not _ret.get('result'):
|
||||
ret['result'] = False
|
||||
ret['result'] = _ret.get('result', False)
|
||||
ret['comment'] = _ret['comment']
|
||||
ret['changes'] = {}
|
||||
return ret
|
||||
@ -277,7 +277,7 @@ def function_present(name, FunctionName, Runtime, Role, Handler, ZipFile=None,
|
||||
_ret = _function_code_present(FunctionName, ZipFile, S3Bucket, S3Key, S3ObjectVersion,
|
||||
region, key, keyid, profile)
|
||||
if not _ret.get('result'):
|
||||
ret['result'] = False
|
||||
ret['result'] = _ret.get('result', False)
|
||||
ret['comment'] = _ret['comment']
|
||||
ret['changes'] = {}
|
||||
return ret
|
||||
@ -286,7 +286,7 @@ def function_present(name, FunctionName, Runtime, Role, Handler, ZipFile=None,
|
||||
_ret = _function_permissions_present(FunctionName, Permissions,
|
||||
region, key, keyid, profile)
|
||||
if not _ret.get('result'):
|
||||
ret['result'] = False
|
||||
ret['result'] = _ret.get('result', False)
|
||||
ret['comment'] = _ret['comment']
|
||||
ret['changes'] = {}
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user