#NEWLINE# def has_privileges( name , object_name , object_type , privileges = None , grant_option = None , prepend = 'public' , maintenance_db = None , user = None , host = None , port = None , password = None , runas = None ) : #NEWLINE# #INDENT# "\n    .. versionadded:: 2016.3.0\n\n    Check if a role has the specified privileges on an object\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' postgres.has_privileges user_name table_name table \\\n        SELECT,INSERT maintenance_db=db_name\n\n    name\n       Name of the role whose privilages should be checked on object_type\n\n    object_name\n       Name of the object on which the check is to be performed\n\n    object_type\n       The object type, which can be one of the following:\n\n       - table\n       - sequence\n       - schema\n       - tablespace\n       - language\n       - database\n       - group\n\n    privileges\n       Comma separated list of privilages to check, from the list below:\n\n       - INSERT\n       - CREATE\n       - TRUNCATE\n       - CONNECT\n       - TRIGGER\n       - SELECT\n       - USAGE\n       - TEMPORARY\n       - UPDATE\n       - EXECUTE\n       - REFERENCES\n       - DELETE\n       - ALL\n\n    grant_option\n        If grant_option is set to True, the grant option check is performed\n\n    prepend\n        Table and Sequence object types live under a schema so this should be\n        provided if the object is not under the default `public` schema\n\n    maintenance_db\n        The database to connect to\n\n    user\n        database username if different from config or default\n\n    password\n        user password if any password for a specified user\n\n    host\n        Database host if different from config or default\n\n    port\n        Database port if different from config or default\n\n    runas\n        System user all operations should be performed on behalf of\n    " #NEWLINE# ( object_type , privileges , _privs ) = _mod_priv_opts ( object_type , privileges ) #NEWLINE# _validate_privileges ( object_type , _privs , privileges ) #NEWLINE# if ( object_type != 'group' ) : #NEWLINE# #INDENT# owner = _get_object_owner ( object_name , object_type , prepend = prepend , maintenance_db = maintenance_db , user = user , host = host , port = port , password = password , runas = runas ) #NEWLINE# if ( ( owner is not None ) and ( name == owner ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# #UNINDENT# _privileges = privileges_list ( object_name , object_type , prepend = prepend , maintenance_db = maintenance_db , user = user , host = host , port = port , password = password , runas = runas ) #NEWLINE# if ( name in _privileges ) : #NEWLINE# #INDENT# if ( object_type == 'group' ) : #NEWLINE# #INDENT# if grant_option : #NEWLINE# #INDENT# retval = _privileges [ name ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# retval = True #NEWLINE# #UNINDENT# return retval #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# _perms = _PRIVILEGE_TYPE_MAP [ object_type ] #NEWLINE# if grant_option : #NEWLINE# #INDENT# perms = dict ( ( ( _PRIVILEGES_MAP [ perm ] , True ) for perm in _perms ) ) #NEWLINE# retval = ( perms == _privileges [ name ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# perms = [ _PRIVILEGES_MAP [ perm ] for perm in _perms ] #NEWLINE# if ( 'ALL' in _privs ) : #NEWLINE# #INDENT# retval = ( perms . sort ( ) == _privileges [ name ] . keys ( ) . sort ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# retval = set ( _privs ) . issubset ( set ( _privileges [ name ] . keys ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return retval #NEWLINE# #UNINDENT# #UNINDENT# return False