o .&a@sddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z dd Zd d ZGd d d e ZGddde ZdS)N) xform_name)Stubber)ArgumentGenerator)CLIOperationCaller)OverrideRequiredArgsArgument) json_encodercCs|dtdS)Nzbuilding-argument-table)registeradd_generate_skeleton)clir K/usr/lib/python3/dist-packages/awscli/customizations/generatecliskeleton.pyregister_generate_cli_skeletonsr cKs$d|vrt||}||dSdS)Noutfile)GenerateCliSkeletonArgumentadd_to_arg_table)sessionoperation_modelargument_tablekwargsgenerate_cli_skeleton_argumentr r r r s r csTeZdZdZddddddgdZfdd Zfd d Zfd d ZddZZ S)rzThis argument writes a generated JSON skeleton to stdout The argument, if present in the command line, will prevent the intended command from taking place. Instead, it will generate a JSON skeleton and print it to standard output. zgenerate-cli-skeletonaJPrints a JSON skeleton to standard output without sending an API request. If provided with no value or the value ``input``, prints a sample input JSON that can be used as an argument for ``--cli-input-json``. If provided with the value ``output``, it validates the command inputs and returns a sample output JSON for that command.?inputoutput)name help_textnargsconstchoicescstt||||_dS)N)superr__init___operation_model)selfrr __class__r r r<s z$GenerateCliSkeletonArgument.__init__cs"|jd|jtt|dS)Nzcalling-command.*)_sessionrgenerate_json_skeletonrr_register_argument_action)r!r"r r r&@sz5GenerateCliSkeletonArgument._register_argument_actionc sld|j}||vr4||}z ||ddkrWdSWn ty$Ynwtt|j||fi|dSdS)Nz--r)rindex IndexErrorrroverride_required_args)r!rargsrarg_name arg_locationr"r r r*Es     z2GenerateCliSkeletonArgument.override_required_argsc Kst|ddrH|jdk}|j}|r"|jj}|j}t|j||||St } |j } | dur/i} n| | } t j tj| dtdt j ddSdS)Ngenerate_cli_skeletonr)indentdefault r)getattrr.r service_model service_namerStubbedCLIOperationCallerr$invoker input_shapegenerate_skeletonsysstdoutwritejsondumpsr) r!call_parameters parsed_argsparsed_globalsr for_outputrr5operation_nameargument_generatoroperation_input_shapeskeletonr r r r%Us.    z2GenerateCliSkeletonArgument.generate_json_skeleton) __name__ __module__ __qualname____doc__ARG_DATArr&r*r% __classcell__r r r"r r&s   rc@seZdZdZddZdS)r6zA stubbed CLIOperationCaller It generates a fake response and uses the response and provided parameters to make a stubbed client call for an operation command. c Cst|}|jj|}i}|jrtdd}||j}t|} | ||t ||di|WdS1s:wYdS)NT)use_member_namesr ) rmetar4r output_shaperr9r add_responser3) r!clientrC parametersrA method_namer fake_responserDstubberr r r _make_client_call{s   $z+StubbedCLIOperationCaller._make_client_callN)rGrHrIrJrVr r r r r6us r6)r=r:botocorer botocore.stubrbotocore.utilsrawscli.clidriverrawscli.customizations.argumentsr awscli.utilsrr r rr6r r r r s        O