>ac@sdZddlmZddlmZmZmZddlmZddl m Z ddl m Z e Z defdYZd efd YZd efd YZd efdYZdefdYZde fdYZdefdYZdefdYZdefdYZdefdYZde fdYZde fdYZde fd YZd!e fd"YZd#e fd$YZd%e fd&YZd'S((s-Abstractions to interact with service models.i(t defaultdict(tCachedPropertytinstance_cachethyphenize_service_id(t OrderedDict(tMissingServiceIdError(tUndefinedModelAttributeErrortNoShapeFoundErrorcBseZRS((t__name__t __module__(((s//usr/lib/fence-agents/bundled/botocore/model.pyRstInvalidShapeErrorcBseZRS((RR (((s//usr/lib/fence-agents/bundled/botocore/model.pyR stOperationNotFoundErrorcBseZRS((RR (((s//usr/lib/fence-agents/bundled/botocore/model.pyR !stInvalidShapeReferenceErrorcBseZRS((RR (((s//usr/lib/fence-agents/bundled/botocore/model.pyR %st ServiceIdcBseZdZRS(cCs t|S(N(R(tself((s//usr/lib/fence-agents/bundled/botocore/model.pyt hyphenize*s(RR R(((s//usr/lib/fence-agents/bundled/botocore/model.pyR )stShapecBseZdZddddddddd d d d d ddddgZddddddddddddg ZeZd$dZe dZ e dZ e d Z d!Z d"Zed#ZRS(%s3Object representing a shape from the service model.t locationNamet queryNamet flattenedtlocationtpayloadt streamingttimestampFormatt xmlNamespacet resultWrappert xmlAttributet eventstreamteventt eventheadert eventpayloadt jsonvaluet hostLabeltrequiredtmintmaxt sensitivetenumtidempotencyTokenterrort exceptiontendpointdiscoveryidt retryabletdocumenttunioncCsb||_|d|_|jdd|_||_|dkrLt}n||_i|_dS(s  :type shape_name: string :param shape_name: The name of the shape. :type shape_model: dict :param shape_model: The shape model. This would be the value associated with the key in the "shapes" dict of the service model (i.e ``model['shapes'][shape_name]``) :type shape_resolver: botocore.model.ShapeResolver :param shape_resolver: A shape resolver object. This is used to resolve references to other shapes. For scalar shape types (string, integer, boolean, etc.), this argument is not required. If a shape_resolver is not provided for a complex type, then a ``ValueError`` will be raised when an attempt to resolve a shape is made. ttypet documentationtN( tnamet type_nametgetR.t _shape_modeltNonetUnresolvableShapeMapt_shape_resolvert_cache(Rt shape_namet shape_modeltshape_resolver((s//usr/lib/fence-agents/bundled/botocore/model.pyt__init__>s      cCsi|j}i}x1|jD]&}||jkr||||tmetadataR@((s//usr/lib/fence-agents/bundled/botocore/model.pyRBs  cCs|jjdgS(sA list of members that are required. A structure shape can define members that are required. This value will return a list of required members. If there are no required members an empty list is returned. R!(RBR2(R((s//usr/lib/fence-agents/bundled/botocore/model.pytrequired_memberss cCs|jj|S(N(R6tresolve_shape_ref(Rt shape_ref((s//usr/lib/fence-agents/bundled/botocore/model.pyt_resolve_shape_refscCsd|jj|jfS(Ns<%s(%s)>(t __class__RR0(R((s//usr/lib/fence-agents/bundled/botocore/model.pyt__repr__s cCsdS(N(R4(R((s//usr/lib/fence-agents/bundled/botocore/model.pytevent_stream_namesN(RR t__doc__R<RARtMAP_TYPER4R;RR?RBRCRFRHtpropertyRI(((s//usr/lib/fence-agents/bundled/botocore/model.pyR.s"      "!  tStructureShapecBsSeZedZedZedZedZedZRS(cCs[|jjd|j}|j}x-|jD]\}}|j|||((s//usr/lib/fence-agents/bundled/botocore/model.pytoperation_model6s  cCs|jjddS(NR.R/(R`R2(R((s//usr/lib/fence-agents/bundled/botocore/model.pyR.>scCst|jjdgS(NRs(RpR`R2(R((s//usr/lib/fence-agents/bundled/botocore/model.pytoperation_namesBscCs!|jdk r|jS|jSdS(sThe name of the service. This defaults to the endpointPrefix defined in the service model. However, this value can be overriden when a ``ServiceModel`` is created. If a service_name was not provided when the ``ServiceModel`` was created and if there is no endpointPrefix defined in the service model, then an ``UndefinedModelAttributeError`` exception will be raised. N(RdR4tendpoint_prefix(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRgFs cCsAyt|jdSWn#tk r<td|jnXdS(Nt serviceIdRg(R t_get_metadata_propertyRRRd(R((s//usr/lib/fence-agents/bundled/botocore/model.pyt service_idWs  cCs.|jjd}|dkr*|j}n|S(sThe name to use when computing signatures. If the model does not define a signing name, this value will be the endpoint prefix defined in the model. t signingNameN(RBR2R4Ry(Rt signing_name((s//usr/lib/fence-agents/bundled/botocore/model.pyR~`s  cCs |jdS(Nt apiVersion(R{(R((s//usr/lib/fence-agents/bundled/botocore/model.pyt api_versionlscCs |jdS(Ntprotocol(R{(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRpscCs |jdS(NtendpointPrefix(R{(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRytscCs4x-|jD]"}|j|}|jr |Sq WdS(N(RxRwtis_endpoint_discovery_operation(Rt operationR>((s//usr/lib/fence-agents/bundled/botocore/model.pytendpoint_discovery_operationxs cCsLxE|jD]:}|j|}|jdk r |jjdr tSq WtS(NR!(RxRwtendpoint_discoveryR4R2tTrueRT(RRR>((s//usr/lib/fence-agents/bundled/botocore/model.pytendpoint_discovery_requireds cCs=y|j|SWn'tk r8td||fnXdS(Ns1"%s" not defined in the metadata of the model: %s(RBRtR(RR0((s//usr/lib/fence-agents/bundled/botocore/model.pyR{s  cCs4|jtkr-|jjd}||_n|jS(NtsignatureVersion(RcRbRBR2(Rtsignature_version((s//usr/lib/fence-agents/bundled/botocore/model.pyRs cCs ||_dS(N(Rc(RR\((s//usr/lib/fence-agents/bundled/botocore/model.pyRscCsd|jj|jfS(Ns%s(%s)(RGRRg(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRHsN(RR RJR4R;RjRlRRkRDRqRmRRwR.RxRgR|R~RRRyRRR{RLRtsetterRH(((s//usr/lib/fence-agents/bundled/botocore/model.pyR^s.        RucBsaeZddZedZedZedZedZ edZ edZ edZ edZ ed Zed Zed Zed Zed ZedZedZedZdZdZdZedZedZdZdZdZdZRS(cCsR||_||_||_|jd|_|j|_|jdi|_dS(s :type operation_model: dict :param operation_model: The operation model. This comes from the service model, and is the value associated with the operation name in the service model (i.e ``model['operations'][op_name]``). :type service_model: botocore.model.ServiceModel :param service_model: The service model associated with the operation. :type name: string :param name: The operation name. This is the operation name exposed to the users of this model. This can potentially be different from the "wire_name", which is the operation name that *must* by provided over the wire. For example, given:: "CreateCloudFrontOriginAccessIdentity":{ "name":"CreateCloudFrontOriginAccessIdentity2014_11_06", ... } The ``name`` would be ``CreateCloudFrontOriginAccessIdentity``, but the ``self.wire_name`` would be ``CreateCloudFrontOriginAccessIdentity2014_11_06``, which is the value we must send in the corresponding HTTP request. R0thttpN(t_operation_modelt_service_modelt _api_nameR2t _wire_nameRBR(RRwt service_modelR0((s//usr/lib/fence-agents/bundled/botocore/model.pyR;s     cCs!|jdk r|jS|jSdS(N(RR4t wire_name(R((s//usr/lib/fence-agents/bundled/botocore/model.pyR0scCs|jjdS(sRThe wire name of the operation. In many situations this is the same value as the ``name``, value, but in some services, the operation name exposed to the user is different from the operaiton name we send across the wire (e.g cloudfront). Any serialization code should use ``wire_name``. R0(RR2(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRs cCs|jS(N(R(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRscCs|jjddS(NR.R/(RR2(R((s//usr/lib/fence-agents/bundled/botocore/model.pyR.scCs|jjdtS(Nt deprecated(RR2RT(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRscCs|jjddS(Ntendpointdiscovery(RR2R4(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRscCs|jjdtS(Ntendpointoperation(RR2RT(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRscCs*d|jkrdS|jj|jdS(Ntinput(RR4RRD(R((s//usr/lib/fence-agents/bundled/botocore/model.pyt input_shapes cCs*d|jkrdS|jj|jdS(Ntoutput(RR4RRD(R((s//usr/lib/fence-agents/bundled/botocore/model.pyt output_shapes cCsU|j}|sgSg|jjD].\}}d|jkr#|jdr#|^q#S(NR&(RRNRORB(RRR0tshape((s//usr/lib/fence-agents/bundled/botocore/model.pytidempotent_memberss  cCs|jjdS(Ntauthtype(RR2(R((s//usr/lib/fence-agents/bundled/botocore/model.pyt auth_typescs/jjdg}tfd|DS(Nterrorsc3s!|]}jj|VqdS(N(RRD(t.0ts(R(s//usr/lib/fence-agents/bundled/botocore/model.pys s(RR2Rp(RR_((Rs//usr/lib/fence-agents/bundled/botocore/model.pyRmscCs|jjdS(Ntendpoint(RR2(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRscCs|jjdtS(NthttpChecksumRequired(RR2RT(R((s//usr/lib/fence-agents/bundled/botocore/model.pythttp_checksum_required!scCs|jdk S(N(tget_event_stream_inputR4(R((s//usr/lib/fence-agents/bundled/botocore/model.pythas_event_stream_input%scCs|jdk S(N(tget_event_stream_outputR4(R((s//usr/lib/fence-agents/bundled/botocore/model.pythas_event_stream_output)scCs|j|jS(N(t_get_event_streamR(R((s//usr/lib/fence-agents/bundled/botocore/model.pyR-scCs|j|jS(N(RR(R((s//usr/lib/fence-agents/bundled/botocore/model.pyR0scCs.|dkrdS|j}|r*|j|SdS(sAReturns the event stream member's shape if any or None otherwise.N(R4RIRN(RRt event_name((s//usr/lib/fence-agents/bundled/botocore/model.pyR3s    cCs|jdk S(N(tget_streaming_inputR4(R((s//usr/lib/fence-agents/bundled/botocore/model.pythas_streaming_input<scCs|jdk S(N(tget_streaming_outputR4(R((s//usr/lib/fence-agents/bundled/botocore/model.pythas_streaming_output@scCs|j|jS(N(t_get_streaming_bodyR(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRDscCs|j|jS(N(RR(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRGscCsU|dkrdS|jjd}|dk rQ|j|}|jdkrQ|SndS(s?Returns the streaming member's shape if any; or None otherwise.RtblobN(R4R?R2RNR1(RRRt payload_shape((s//usr/lib/fence-agents/bundled/botocore/model.pyRJs   cCsd|jj|jfS(Ns %s(name=%s)(RGRR0(R((s//usr/lib/fence-agents/bundled/botocore/model.pyRHUsN(RR R4R;RR0RLRRR.RRRRRRRRmRRRRRRRRRRRRRH(((s//usr/lib/fence-agents/bundled/botocore/model.pyRus4 %         RacBsNeZdZied6ed6ed6ed6ZdZddZ dZ RS( sResolves shape references.t structureRptmaptstringcCs||_i|_dS(N(t _shape_mapt _shape_cache(Rt shape_map((s//usr/lib/fence-agents/bundled/botocore/model.pyR;ds cCsy|j|}Wntk r0t|nXy|jj|dt}Wn!tk rqtd|nX|r|j}|j|n||||}|S(NR-s(Shape is missing required key 'type': %s( RRtRt SHAPE_CLASSESR2RR tcopytupdate(RR8RiR9t shape_clstresult((s//usr/lib/fence-agents/bundled/botocore/model.pyRhhs   cCst|dkr/d|kr/|j|dS|j}y|jd}Wn!tk rqtd|nX|j||SdS(NiRs*Invalid model, missing shape reference: %s(tlenRhRR=RtR (RRERiR8((s//usr/lib/fence-agents/bundled/botocore/model.pyRDxs  N( RR RJRMRYRZR]RR;R4RhRD(((s//usr/lib/fence-agents/bundled/botocore/model.pyRaYs   R5cBs#eZdZddZdZRS(sJA ShapeResolver that will throw ValueErrors when shapes are resolved. cCstddS(Ns>Attempted to lookup shape '%s', but no shape map was provided.(t ValueError(RR8Ri((s//usr/lib/fence-agents/bundled/botocore/model.pyRhscCstddS(Ns?Attempted to resolve shape '%s', but no shape map was provided.(R(RRE((s//usr/lib/fence-agents/bundled/botocore/model.pyRDsN(RR RJR4RhRD(((s//usr/lib/fence-agents/bundled/botocore/model.pyR5s tDenormalizedStructureBuildercBskeZdZd dZdZdZdZdZdZ dZ dZ d Z d Z RS( sBuild a StructureShape from a denormalized model. This is a convenience builder class that makes it easy to construct ``StructureShape``s based on a denormalized model. It will handle the details of creating unique shape names and creating the appropriate shape map needed by the ``StructureShape`` class. Example usage:: builder = DenormalizedStructureBuilder() shape = builder.with_members({ 'A': { 'type': 'structure', 'members': { 'B': { 'type': 'structure', 'members': { 'C': { 'type': 'string', } } } } } }).build_model() # ``shape`` is now an instance of botocore.model.StructureShape :type dict_type: class :param dict_type: The dictionary type to use, allowing you to opt-in to using OrderedDict or another dict type. This can be particularly useful for testing when order matters, such as for documentation. cCs@t|_t|_|dkr<|jjd|_ndS(NR(RRNtShapeNameGeneratort_name_generatorR4tnew_shape_nameR0(RR0((s//usr/lib/fence-agents/bundled/botocore/model.pyR;s   cCs ||_|S(sp :type members: dict :param members: The denormalized members. :return: self (t_members(RRN((s//usr/lib/fence-agents/bundled/botocore/model.pyt with_memberss cCsht}idd6|jd6}|j|||jtd|}td|jd||jd|S(sBuild the model based on the provided members. :rtype: botocore.model.StructureShape :return: The built StructureShape object. RR-RNRR8R9R:(RRt _build_modelR0RaRM(RR_t denormalizedtresolver((s//usr/lib/fence-agents/bundled/botocore/model.pyt build_models   c Cs|ddkr)|j||||R_R8((s//usr/lib/fence-agents/bundled/botocore/model.pyRs cCst}|j|}||dW|S(NRNR(Rt_build_initial_shapeR2ROt_get_shape_nameR(RR>R_RNRR0t member_modeltmember_shape_name((s//usr/lib/fence-agents/bundled/botocore/model.pyRs  (cCsJ|j|}|j|}i|d6|d<|j|d|||S(NRRR(RRR(RR>R_RR((s//usr/lib/fence-agents/bundled/botocore/model.pyRs cCs|j|d}|j|d}|j|}i|d6|dR_tkey_shape_nametvalue_shape_nameR((s//usr/lib/fence-agents/bundled/botocore/model.pyRscCsci|dd6}d|kr.|d|dRR@((s//usr/lib/fence-agents/bundled/botocore/model.pyR s  cCs |j|S(N(R(RR>((s//usr/lib/fence-agents/bundled/botocore/model.pyRscCs,d|kr|dS|jj|dSdS(NR8R-(RR(RR>((s//usr/lib/fence-agents/bundled/botocore/model.pyRs N(RR RJR4R;RRRRRRRRR(((s//usr/lib/fence-agents/bundled/botocore/model.pyRs#    RcBs eZdZdZdZRS(sGenerate unique shape names for a type. This class can be used in conjunction with the DenormalizedStructureBuilder to generate unique shape names for a given type. cCstt|_dS(N(Rtintt _name_cache(R((s//usr/lib/fence-agents/bundled/botocore/model.pyR;&scCs4|j|cd7<|j|}d|j|fS(sGenerate a unique shape name. This method will guarantee a unique shape name each time it is called with the same type. :: >>> s = ShapeNameGenerator() >>> s.new_shape_name('structure') 'StructureType1' >>> s.new_shape_name('structure') 'StructureType2' >>> s.new_shape_name('list') 'ListType1' >>> s.new_shape_name('list') 'ListType2' :type type_name: string :param type_name: The type name (structure, list, map, string, etc.) :rtype: string :return: A unique shape name for the given type is%sType%s(Rt capitalize(RR1t current_index((s//usr/lib/fence-agents/bundled/botocore/model.pyR)s  (RR RJR;R(((s//usr/lib/fence-agents/bundled/botocore/model.pyRs N( RJt collectionsRtbotocore.utilsRRRtbotocore.compatRtbotocore.exceptionsRRtobjectRbt ExceptionRR R R tstrR RRMRYRZR]R^RuRaR5RR(((s//usr/lib/fence-agents/bundled/botocore/model.pyt s, * 4