HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/aws_sqs.cpython-310.pyc
o

�N�g�@s�dZddlZddlZddlZe�e�ZdZdd�Z	dd�Z
dd	�Zddd�Zdd
d�Z
ddd�Zddd�Zddd�Zddd�Zdd�ZdS)z.
Support for the Amazon Simple Queue Service.
�Nz
--output jsoncCstjj�d�r	dSdS)NZawsT)Fz=The module aws_sqs could not be loaded: aws command not found)�salt�utils�path�which�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/aws_sqs.py�__virtual__srcCs
d|��S)z%
    Return the region argument.
    z
 --region r)�regionrrr�_regions
r
c	Ks�|�dd�}|r||d<|�dd�}|r||d<dd�|��D�}dj|d	�|�t|�td
�}td||dd
�}|rAtjj	�
|�SdS)z�
    Runs the given command against AWS.
    cmd
        Command to run
    region
        Region to execute cmd in
    opts
        Pass in from salt
    user
        Pass in from salt
    kwargs
        Key-value arguments to pass to the command
    �
receipthandleNzreceipt-handle�numzmax-number-of-messagescSs"g|]
\}}d|�d|�d��qS)z--z "�"r)�.0�k�vrrr�
<listcomp>4s"z_run_aws.<locals>.<listcomp>z#aws sqs {cmd} {args} {region} {out}� )�cmd�argsr	�outzcmd.runF)ZrunasZpython_shell�)�pop�items�format�joinr
�_OUTPUTZ__salt__rr�json�loads)	rr	�opts�user�kwargsrrZ_formatted_args�rtnrrr�_run_awss�r"�c	Cs\ddi}t|||�}t|�}||vrt�d|�|Std||||||d�}|d|d<|S)aU
    Receive one or more messages from a queue in a region

    queue
        The name of the queue to receive messages from

    region
        Region where SQS queues exists

    num : 1
        The max number of messages to receive

    opts : None
        Any additional options to add to the command line

    user : None
        Run as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' aws_sqs.receive_message <sqs queue> <region>
        salt '*' aws_sqs.receive_message <sqs queue> <region> num=10

    .. versionadded:: 2014.7.0

    ZMessagesN�"%s" queue does not exist.zreceive-message)�queuer��list_queues�_parse_queue_list�log�infor")	r%r	rrr�ret�queues�url_maprrrr�receive_message?s�r.cCsHt|||�}t|�}||vrt�d|�dStd||||||d�}dS)a�
    Delete one or more messages from a queue in a region

    queue
        The name of the queue to delete messages from

    region
        Region where SQS queues exists

    receipthandle
        The ReceiptHandle of the message to delete. The ReceiptHandle
        is obtained in the return from receive_message

    opts : None
        Any additional options to add to the command line

    user : None
        Run as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' aws_sqs.delete_message <sqs queue> <region> receipthandle='<sqs ReceiptHandle>'

    .. versionadded:: 2014.7.0

    r$Fzdelete-message)rr%Tr&)r%r	rrrr,r-rrrr�delete_messagejs�r/cCs td|||�}d|dd�}|S)aW
    List the queues in the selected region.

    region
        Region to list SQS queues for

    opts : None
        Any additional options to add to the command line

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' aws_sqs.list_queues <region>

    zlist-queuesrZ	QueueUrls)�retcode�stdout�r")r	rrrr+rrrr'�s
�r'cCs2d|i}td	|||d�|��}d|ddd�}|S)
a�
    Creates a queue with the correct name.

    name
        Name of the SQS queue to create

    region
        Region to create the SQS queue in

    opts : None
        Any additional options to add to the command line

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' aws_sqs.create_queue <sqs queue> <region>

    z
queue-name�create-queue�r	rrrZQueueUrlr�r0r1�stderrN)r3r2)�namer	rr�createrr+rrr�create_queue�s�r9cCs�t|||�}t|�}t�d|�||vr/d||i}td|||d�|��}d}d}	|�d�}
nd}
d}	d	}|r9d
nd|
|	d�}|S)a�
    Deletes a queue in the region.

    name
        Name of the SQS queue to deletes
    region
        Name of the region to delete the queue from

    opts : None
        Any additional options to add to the command line

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' aws_sqs.delete_queue <sqs queue> <region>

    zmap %sz	queue-url�delete-queuer4Trz deletedz
Delete failedFrr#r5N)r:)r'r(r)�debugr")r7r	rrr,r-�deleter!�success�errrr+rrr�delete_queue�s"
�r?cCst|||�}|t|�vS)a�
    Returns True or False on whether the queue exists in the region

    name
        Name of the SQS queue to search for

    region
        Name of the region to search for the queue in

    opts : None
        Any additional options to add to the command line

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' aws_sqs.queue_exists <sqs queue> <region>

    )r'r()r7r	rr�outputrrr�queue_existssrAcCsdd�|dD�}|S)z6
    Parse the queue to get a dict of name -> URL
    cSsi|]
}|�d�d|�qS)�/���)�split)r�qrrr�
<dictcomp>'sz%_parse_queue_list.<locals>.<dictcomp>r1r)Zlist_outputr,rrrr(#sr()r#NN)NN)�__doc__�loggingZsalt.utils.jsonrZsalt.utils.path�	getLogger�__name__r)rrr
r"r.r/r'r9r?rAr(rrrr�<module>s 

"
+
.

#
/