def get_permissions(FunctionName, Qualifier=None, region=None, key=None, keyid=None, profile=None):
 try:
  conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
  kwargs = {}
  if (Qualifier is not None):
   kwargs['Qualifier'] = Qualifier
  policy = conn.get_policy(FunctionName=FunctionName, **kwargs)
  policy = policy.get('Policy', {})
  if isinstance(policy, six.string_types):
   policy = json.loads(policy)
  if (policy is None):
   policy = {}
  permissions = {}
  for statement in policy.get('Statement', []):
   condition = statement.get('Condition', {})
   principal = statement.get('Principal', {})
   if ('AWS' in principal):
    principal = principal['AWS'].split(':')[4]
   else:
    principal = principal.get('Service')
   permission = {'Action': statement.get('Action'), 'Principal': principal}
   if ('ArnLike' in condition):
    permission['SourceArn'] = condition['ArnLike'].get('AWS:SourceArn')
   if ('StringEquals' in condition):
    permission['SourceAccount'] = condition['StringEquals'].get('AWS:SourceAccount')
   permissions[statement.get('Sid')] = permission
  return {'permissions': permissions}
 except ClientError as e:
  err = salt.utils.boto3.get_error(e)
  if (e.response.get('Error', {}).get('Code') == 'ResourceNotFoundException'):
   return {'permissions': None}
  return {'permissions': None, 'error': err}

def get_permissions ( FunctionName , Qualifier = None , region = None , key = None , keyid = None , profile = None ) : try : conn = _get_conn ( region = region , key = key , keyid = keyid , profile = profile ) kwargs = { } if ( Qualifier is not None ) : kwargs [ 'Qualifier' ] = Qualifier policy = conn . get_policy ( FunctionName = FunctionName , ** kwargs ) policy = policy . get ( 'Policy' , { } ) if isinstance ( policy , six . string_types ) : policy = json . loads ( policy ) if ( policy is None ) : policy = { } permissions = { } for statement in policy . get ( 'Statement' , [ ] ) : condition = statement . get ( 'Condition' , { } ) principal = statement . get ( 'Principal' , { } ) if ( 'AWS' in principal ) : principal = principal [ 'AWS' ] . split ( ':' ) [ 4 ] else : principal = principal . get ( 'Service' ) permission = { 'Action' : statement . get ( 'Action' ) , 'Principal' : principal } if ( 'ArnLike' in condition ) : permission [ 'SourceArn' ] = condition [ 'ArnLike' ] . get ( 'AWS:SourceArn' ) if ( 'StringEquals' in condition ) : permission [ 'SourceAccount' ] = condition [ 'StringEquals' ] . get ( 'AWS:SourceAccount' ) permissions [ statement . get ( 'Sid' ) ] = permission return { 'permissions' : permissions } except ClientError as e : err = salt . utils . boto3 . get_error ( e ) if ( e . response . get ( 'Error' , { } ) . get ( 'Code' ) == 'ResourceNotFoundException' ) : return { 'permissions' : None } return { 'permissions' : None , 'error' : err }
get the permissions for the passed object args: obj_name : the name of or path to the object .