Qc;@sdZdddgZddkZddkZddkZddkZddkZddkZddkZddk Z ddk Z ddk Z ddk Z yddk l Z Wn#ej oddkl Z nXddklZddklZdd klZdd klZdd klZdd klZdd klZddklZddklZddklZddklZddklZddkl Z ddk!l"Z"ddk#l$Z$ddk%l&Z&ei'e(Z)ei*dZ+ei*dZ,dZ-dZ.ddddgZ/dd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:gZ0d;Z1d<Z2d=Z3de-dded>Z5dddded?Z6d@Z7hdLdC6dMdE6dNdG6dOdI6Z8dJZ9dKZ:dS(PsUClient for discovery based APIs A client library for Google's discovery based APIs. tbuildt"build_from_documentfix_method_namet key2paramiN(t parse_qsl(t HttpError(tInvalidJsonError(tMediaUploadSizeError(tUnacceptableMimeTypeError(tUnknownApiNameOrVersion(tUnknownLinkType(t HttpRequest(tMediaFileUpload(t MediaUpload(t JsonModel(t MediaModel(tRawModel(tSchemas(t MIMEMultipart(tMIMENonMultipart(t simplejsons{[^}]*}s[a-zA-Z0-9_-]+sDhttps://www.googleapis.com/discovery/v1/apis/{api}/{apiVersion}/rests)A description of how to use this functionttracetpptuseriptstricttandtasserttbreaktclasstcontinuetdeftdelteliftelsetexcepttexectfinallytfortfromtglobaltiftimporttintistlambdatnottortpasstprinttraisetreturnttrytwhilecCs|tjo |dS|SdS(sFix method names to avoid reserved word conflicts. Args: name: string, method name. Returns: The name with a '_' prefixed if the name is a reserved word. t_N(tRESERVED_WORDS(tname((sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pytfix_method_namePs  cCsk|djo|Stti|}tt|d}||| "max_results" Args: key: string, the method key name. Returns: A safe method name based on the key name. itxR4t(R9tisalphatappendtisalnumtjoin(tkeytresulttc((sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyRvs   c CsPh|d6|d6}|djoti}nti||}dtijot|dtid}nti d||i |\} } | i djot d||fn| i djot | | |nyti| } Wn/tj o#} tid | tnXt| |d |d |d |d |S(sConstruct a Resource for interacting with an API. Construct a Resource object for interacting with an API. The serviceName and version are the names from the Discovery service. Args: serviceName: string, name of the service. version: string, the version of the service. http: httplib2.Http, An instance of httplib2.Http or something that acts like it that HTTP requests will be made through. discoveryServiceUrl: string, a URI Template that points to the location of the discovery service. It should have two parameters {api} and {apiVersion} that when filled in produce an absolute URI to the discovery document for that service. developerKey: string, key obtained from https://code.google.com/apis/console. model: apiclient.Model, converts to and from the wire format. requestBuilder: apiclient.http.HttpRequest, encapsulator for an HTTP request. Returns: A Resource object with methods for interacting with the service. tapit apiVersiont REMOTE_ADDRtuserIpsURL being requested: %sisname: %s version: %sisFailed to parse as JSON: thttpt developerKeytmodeltrequestBuilderN(R8thttplib2tHttpt uritemplatetexpandtostenvironRCtloggertinfotrequesttstatusRRRtloadst ValueErrorterrorRtbuild_from_document( t serviceNametversionRQtdiscoveryServiceUrlRRRSRTtparamst requested_urltresptcontenttservicete((sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyRs.    c Csh}ti|}ti||d}t|}|djo(|idg}td|j}nt||||||||} | S(snCreate a Resource for interacting with an API. Same as `build()`, but constructs the Resource object from a discovery document that is it given, as opposed to retrieving one over HTTP. Args: service: string, discovery document. base: string, base URI for all HTTP requests, usually the discovery URI. future: string, discovery document with future capabilities (deprecated). http: httplib2.Http, An instance of httplib2.Http or something that acts like it that HTTP requests will be made through. developerKey: string, Key for controlling API usage, generated from the API Console. model: Model class instance that serializes and de-serializes requests and responses. requestBuilder: Takes an http request and packages it up to be executed. Returns: A Resource object with methods for interacting with the service. tbasePathtfeaturest dataWrapperN( RR_R:turljoinRR8tgetR t_createResource( RjtbasetfutureRQRRRSRTtschemaRmtresource((sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyRbs  cCs|djoEt|tdjpt|tdjo|St|Sn|djott|S|djott|S|djott|iSt|tdjpt|tdjo|St|SdS(sVConvert value to a string based on JSON Schema type. See http://tools.ietf.org/html/draft-zyp-json-schema-03 for more details on JSON Schema. Args: value: any, the value to convert schema_type: string, the type that value should be interpreted as Returns: A string representation of 'value' based on the schema_type. tstringREutintegertnumbertbooleanN(ttypetstrtinttfloattbooltlower(R@t schema_type((sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyt_casts 2   2ii tKBitMBitGBi(tTBcCsbt|djodS|di}ti|d}|ot|d |St|SdS(sConvert a string media size, such as 10GB or 3TB into an integer. Args: maxSize: string, size as a string, such as 2MB or 7GB. Returns: The size as an integer value. iiiN(tlentuppert MULTIPLIERSRpR|(tmaxSizetunitst multiplier((sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyt_media_size_to_long%s c sdtffdY}fd} d} d|jofx_|diD]M\} } | || | || idto| || d| |nqaWnd|joGfd } x1|diD]\} } | || | |qWnd|jox|diD]\} } d | jo| d }d |joi|d }nd |id hj}d| idhj}|o|o#| || d|d| | nnq(Wn|S(sgBuild a Resource from the API description. Args: http: httplib2.Http, Object to make http requests with. baseUrl: string, base URL for the API. All requests are relative to this URI. model: apiclient.Model, converts to and from the wire format. requestBuilder: class or callable that instantiates an apiclient.HttpRequest object. developerKey: string, key obtained from https://code.google.com/apis/console resourceDesc: object, section of deserialized discovery document that describes a resource. Note that the top level discovery document is considered a resource. rootDesc: object, the entire deserialized discovery document. schema: object, mapping of schema names to schema descriptions. Returns: An instance of Resource with all the methods attached for interacting with that resource. tResourcecs)eZdZfdZRS(s(A class for interacting with a resource.cs1|_|_|_|_|_dS(N(t_httpt_baseUrlt_modelt _developerKeyt_requestBuilder(tself(RQtbaseUrlRRRTRS(sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyt__init__Ss     (t__name__t __module__t__doc__R((RQRRRRTRS(sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyRPscsxtd d d d/gddjo]d}tti}|d}d| |dt|id d nd johd |i%|d<|i&d|i!}t$|dd}q)t'd}t(|ddt)|di*d} | i+||i,| t)|i%i*d} d| d<|i&d|i!}!| i+|!|i,| |i-}|i.}d||d2st/tbinarysContent-Transfer-Encodings multipart/related; boundary="%s"t multipartsURL being requested: %stmethodtheaderstmethodId(4titerkeyst TypeErrortkeysR8t iteritemst isinstancet basestringtretmatchR{RpRzRRRtendswithRRR]RWRXR:RoRt mimetypest guess_typetUnknownFileTypet mimeparset best_matchRIRR R tsizeRRRCtmimetypetgetbytesRtsetattrRtsplitt set_payloadtattacht as_stringt get_boundaryR[R\RRR("RtkwargsR6RtregextpvaluestpvaluetenumstvaluesR@tactual_query_paramstactual_path_paramsRJtto_typet_[1]RDt cast_valuet body_valuetmedia_filenameRSRRfRRt expanded_urlR?Rtmultipart_boundarytmedia_mime_typetencodingt media_uploadtmsgRoottmsgtpayload(targmapt query_paramst methodNamet mediaPathUrlRtpathUrlRt param_typetpattern_paramst methodDescRtrepeated_paramstrequired_paramst path_paramsRt enum_params(sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyRs       #     ) &.                          s sArgs: s (repeated)s (required)s A parameters$refs< %s: object, %s%s%s The object takes the form of: %s s %s: %s, %s%s%s tenumDescriptionss Allowed values s %s - %s RRs/ Returns: The media object as a string. s( Returns: An object of the form: RN(sPUTsPOSTsPATCH(R7R8R9R:RRpRtSTACK_QUERY_PARAMETERStTruetupdatetFalseRRGt URITEMPLATEtfinditertVARNAMEtgrouptremovetDEFAULT_METHOD_DOCRRRtprettyPrintByNametzipRtprettyPrintSchemaRRI(ttheclassRRtrootDescRRARlR6tdesctargtparamRt namematchRtdocstskip_parametersRRt paramdesctparamdoct paramtypeRtenumDesc(RtR(RRRRRRRRRRRRRRRRsd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyt createMethodZs                  <            #  cSs7t|}|dd}d}t|||dS(sCreates any _next methods for attaching to a Resource. The _next methods allow for easy iteration through list() responses. Args: theclass: type, the class to attach methods to. methodName: string, name of the method to use. methodDesc: object, fragment of deserialized discovery document that describes the method. rootDesc: object, the entire deserialized discovery document. Rs.nextc Ssd|jodSti|}|d}tti|i}t|d}g}|D]*\}} |djo||| fq^q^~} | id|fti| |dR[R\( Rtprevious_requesttprevious_responseR]RRARBRRJR@tnewqR((sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyt methodNexts  > N(R7R(RRRRRR((sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pytcreateNextMethod~s  #tmethodstsupportsMediaDownloadRt resourcescsUt|}fd}t|ddt|dtt|||dS(srCreate a method on the Resource to access a nested Resource. Args: theclass: type, the class to attach methods to. methodName: string, name of the method to use. methodDesc: object, fragment of deserialized discovery document that describes the method. rootDesc: object, the entire deserialized discovery document. c s.t|i|i|i|i|iS(N(RqRRRRR(R(RRRt(sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pytmethodResources RsA collection resource.t__is_resource__N(R7RR(RRRRR(Rt(RRsd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pytcreateResourceMethods Rs$refRt propertiesRRt_next(RRRpR(RQRRSRTRRt resourceDescRRtRR RRRRtresponseSchemathasNextPageTokent hasPageToken((RQRRRRTRSRtsd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyRq8s<( % 5  #           iii@I(;Rt__all__RRUtloggingRYtrandomRRWR<R:RRRt ImportErrortcgitapiclient.errorsRRRRRR tapiclient.httpR R R tapiclient.modelR RRtapiclient.schemaRtemail.mime.multipartRtemail.mime.nonmultipartRtoauth2client.anyjsonRt getLoggerRR[tcompileRRt DISCOVERY_URIRRR5R7RCRR8RRbRRRRq(((sd/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.pyts                @ &