File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_dynamodb.cpython-310.pyc
Back
o ;j�; � @ s~ d Z ddlZddlZddlZddlmZ e�e�Z e�d�� ej� z9ddlZddl Z ddlZddlZddlmZmZmZmZmZmZ ddlmZ ddlmZ e�d�� ej� dZW n eyf d ZY nw e�e�Z d d� Z d"dd �Zd"dd�Z d"dd�Z d#dd�Z!d"dd�Z"d"dd�Z# d$dd�Z$ d"dd�Z% d"dd�Z&d"dd�Z'd%d d!�Z(dS )&a� Connection module for Amazon DynamoDB .. versionadded:: 2015.5.0 :configuration: This module accepts explicit DynamoDB credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More Information available at: .. code-block:: text http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html If IAM roles are not used you need to specify them either in a pillar or in the minion's config file: .. code-block:: yaml keyid: GKTADJGHEIQSXMKKRBJ08H key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs A region may also be specified in the configuration: .. code-block:: yaml region: us-east-1 If a region is not specified, the default is us-east-1. It's also possible to specify key, keyid and region via a profile, either as a passed in dict, or as a string to pull from pillars or minion config: .. code-block:: yaml myprofile: keyid: GKTADJGHEIQSXMKKRBJ08H key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 :depends: boto � N)�SaltInvocationError�boto)�AllIndex�GlobalAllIndex�GlobalIncludeIndex�GlobalKeysOnlyIndex�HashKey�RangeKey)�Table)�JSONResponseErrorTFc C s* t jj�� } | du rtd tdtd� | S )z, Only load if boto libraries exist. Tzboto.assign_funcsZ dynamodb2)�pack)�salt�utilsZversionsZcheck_boto_reqs� __utils__�__name__Z__salt__)Z has_boto_reqs� r �N/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_dynamodb.py�__virtual__U s r c C s* t d d||||d�}d}d}g }|r�z,t�d| � d} | dur8|j| | d �} || �d g �7 }| �d�} | dus dd � |D �W S tjjyS } ztt |���d}~w tjj y� } z2|r|j�di ��d�dkr|d8 }t�d|� t� |� W Y d}~qt�d| |j� W Y d}~dS d}~ww dS )a) Returns a dictionary of all tags currently attached to a given resource. CLI Example: .. code-block:: bash salt myminion boto_dynamodb.list_tags_of_resource resource_arn=arn:aws:dynamodb:us-east-1:012345678901:table/my-table .. versionadded:: 3006.0 �boto3.get_connection�dynamodb��region�key�keyid�profile� � zGarnering tags of resource %s� N)�ResourceArn� NextToken�Tagsr c S s i | ] }|d |d �qS �ZKeyZValuer )�.0�tagr r r � <dictcomp>~ � z)list_tags_of_resource.<locals>.<dictcomp>�Error�Code� Throttling� �/Throttled by AWS API, retrying in %s seconds...z'Failed to list tags for resource %s: %sF)r �log�debug�list_tags_of_resource�get�botocore� exceptions�ParamValidationErrorr �str�ClientError�response�time�sleep�error�message)�resource_arnr r r r �conn3�retriesr6 �tags�marker�ret�errr r r r- _ sD �� �� ����r- c C s t d d||||d�}d}d}t|t�rdd� |�� D �}|r�zt�d| � |j| |d � W d S tjj yC } zt t| ���d} ~ w tjjy� } z2|ro| j �di ��d �dkro|d8 }t�d|� t�|� W Y d} ~ qt�d| | j� W Y d} ~ dS d} ~ ww dS )aK Sets given tags (provided as list or dict) on the given resource. CLI Example: .. code-block:: bash salt myminion boto_dynamodb.tag_resource resource_arn=arn:aws:dynamodb:us-east-1:012345678901:table/my-table tags='{Name: my-table, Owner: Ops}' .. versionadded:: 3006.0 r r r r r c S s g | ] \}}||d ��qS )r! r )r"