HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/self/root/lib/python3.6/site-packages/awscli/__pycache__/schema.cpython-36.opt-1.pyc
3

�T_��@s@ddlmZGdd�de�ZGdd�de�ZGdd�de�ZdS)	�)�defaultdictc@seZdZdS)�ParameterRequiredErrorN)�__name__�
__module__�__qualname__�rr�/usr/lib/python3.6/schema.pyrsrc@sbeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�SchemaTransformeraE
    Transforms a custom argument parameter schema into an internal
    model representation so that it can be treated like a normal
    service model. This includes shorthand JSON parsing and
    automatic documentation generation. The format of the schema
    follows JSON Schema, which can be found here:

    http://json-schema.org/

    Only a relevant subset of features is supported here:

    * Types: `object`, `array`, `string`, `integer`, `boolean`
    * Properties: `type`, `description`, `required`, `enum`

    For example::

    {
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "arg1": {
                    "type": "string",
                    "required": True,
                    "enum": [
                        "Value1",
                        "Value2",
                        "Value3"
                    ]
                },
                "arg2": {
                    "type": "integer",
                    "description": "The number of calls"
                }
            }
        }
    }

    Assuming the schema is applied to a service named `foo`, with an
    operation named `bar` and that the parameter is called `baz`, you
    could call it with the shorthand JSON like so::

        $ aws foo bar --baz arg1=Value1,arg2=5 arg1=Value2

    Z	structure�list)�object�arraycCst�|_dS)N)�ShapeNameGenerator�_shape_namer)�selfrrr�__init__GszSchemaTransformer.__init__cCsi}|j||d�|S)a�Convert JSON schema to the format used internally by the AWS CLI.

        :type schema: dict
        :param schema: The JSON schema describing the argument model.

        :rtype: dict
        :return: The transformed model in a form that can be consumed
            internally by the AWS CLI.  The dictionary returned will
            have a list of shapes, where the shape representing the
            transformed schema is always named ``InputShape`` in the
            returned dictionary.

        Z
InputShape)�
_transform)r�schema�shapesrrr�	transformJszSchemaTransformer.transformcCs|d|krtd��|ddkr.|j||�||<nJ|ddkrL|j||�||<n,|ddkrj|j||�||<n|j|�||<|S)N�typezMissing required key: 'type'rr�map)r�_transform_structure�_transform_list�_transform_map�_transform_scalar)rrr�
shape_namerrrr\szSchemaTransformer._transformcCs
|j|�S)N)�_populate_initial_shape)rrrrrrisz#SchemaTransformer._transform_scalarc
Cs�|j|�}i}g}x^|dj�D]N\}}|j|�}|jj|�}	d|	i||<|jdd�r`|j|�|j|||	�q W||d<|r�||d<|S)NZ
properties�shapeZrequiredF�members)r�items�_json_schema_to_aws_typer�new_shape_name�get�appendr)
rrr�structure_shaperZrequired_members�key�valueZcurrent_type_nameZcurrent_shape_namerrrrls


z&SchemaTransformer._transform_structurecCsT|j|�}xDdD]<}|j||�}|jj|�}d|i||<|j||||�qW|S)Nr%r&r)r%r&)rr rr!r)rrrr$Z	attribute�	type_namerrrrr�s

z SchemaTransformer._transform_mapcCsF|j|�}|j|d�}|jj|�}d|i|d<|j|d||�|S)Nrr�member)rr rr!r)rrrZ
list_shape�member_typeZmember_shape_namerrrr�s
z!SchemaTransformer._transform_listcCs:d|j|�i}d|kr"|d|d<d|kr6|d|d<|S)Nr�descriptionZ
documentation�enum)r )rrrrrrr�sz)SchemaTransformer._populate_initial_shapecCs&d|krtd��|d}|jj||�S)NrzMissing required key: 'type')r�JSON_SCHEMA_TO_AWS_TYPESr")rrr'rrrr �sz*SchemaTransformer._json_schema_to_aws_typeN)rrr�__doc__r,rrrrrrrrr rrrrr	s-
	r	c@seZdZdd�Zdd�ZdS)r
cCstt�|_dS)N)r�int�_name_cache)rrrrr�szShapeNameGenerator.__init__cCs,|j|d7<|j|}d|j�|fS)N�z%sType%s)r/�
capitalize)rr'Z
current_indexrrrr!�s
z!ShapeNameGenerator.new_shape_nameN)rrrrr!rrrrr
�sr
N)�collectionsr�
ValueErrorrrr	r
rrrr�<module>
s