File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/netapi/__pycache__/__init__.cpython-310.pyc
o
�N�g�) � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddl Zddl
ZddlZddlZddl
ZddlZddlZddlZddlmZ e�e�Zdd� Zdd� ZG dd � d �Zd
d� ejedd�D �ZdS )
z
Make api awesomeness
� N)�DEFAULT_TARGET_DELIMc C sZ g }g }| D ]}t |t�r||v rq|�|� q||v rq|�|� qt|�t|td� S )zZ
Return a sorted list of the passed in permissions, de-duplicating in the process
��key)�
isinstance�str�append�sorted�repr)�permsZ
_str_permsZ_non_str_perms�entry� r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/netapi/__init__.py�sorted_permissions s
r c C sv |� | d g �}|�|� dg �� d| v r9| d r9t| d �}dd� |�� D �}||@ D ]}|�||� d� � q,|S )zN
Returns the sum of '*', user-specific and group specific permissions
�name�*�groupsc S s h | ]}|� d �r|�d ��qS )�%)�endswith�rstrip)�.0�ir r r
� <setcomp>5 s z"sum_permissions.<locals>.<setcomp>r )�get�extend�set�keys)�token�eauthr
Zuser_groupsZeauth_groups�groupr r r
�sum_permissions, s r c @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
d dd�Zdd� Zdd� Zdd� ZdS )!�NetapiClienta'
Provide a uniform method of accessing the various client interfaces in Salt
in the form of low-data data structures. For example:
>>> client = NetapiClient(__opts__)
>>> lowstate = {'client': 'local', 'tgt': '*', 'fun': 'test.ping', 'arg': ''}
>>> client.run(lowstate)
c C s� || _ t�| j �}d|d<