File: //lib/python3/dist-packages/awscli/__pycache__/schema.cpython-310.pyc
o
2&�a� � @ s@ d dl mZ G dd� de�ZG dd� de�ZG dd� de�ZdS ) � )�defaultdictc @ s e Zd ZdS )�ParameterRequiredErrorN)�__name__�
__module__�__qualname__� r r �//usr/lib/python3/dist-packages/awscli/schema.pyr s r c @ sb e Zd ZdZddd�Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dd� Zdd� Zdd� 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
� structure�list)�object�arrayc C s t � | _d S �N)�ShapeNameGenerator�_shape_namer��selfr r r �__init__G s zSchemaTransformer.__init__c C s i }| � ||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.
�
InputShape)�
_transform)r �schema�shapesr r r � transformJ s zSchemaTransformer.transformc C s� d|vrt d��|d dkr| �||�||<