!;i%HdZddlmZdZgdZddlmZddlZddlZddl m Z ddl m Z dd l mZddlmZddlZddlZddlZddlZddlZddlZddlZddlZddlZdd lmZdd lmZdd l m!Z!ddl"Z"ddl#Z# ddl$Z$n #e%$rdZ$YnwxYw dd l&m'Z'dZ(n #e%$rdZ(YnwxYwddl)m*Z*m+Z+ddl,m-Z-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;mm?Z?m@Z@mAZAddlBmCZCde"_DejEeFZGejHdZIejHdZJdZKeKZLdZMdZNeOgdZPdddd d!ZQd"d#d$ZRd%d&dd'ZSd(d&dd'ZTd)ZUd*ZVd+ZWd,ZXd-ZYeOgd.ZZd&d/d0Z[Gd1d2e\Z]eOd3gZ^Gd4d5e Z_d6Z`d7Zae.d8dddde:dddddddddfd9Zbd:Zc dPd;Zdd<Zee.dddddde:dddddf d=Zfd>Zgd?Zhd@ZidAZjdBZkdCZldDZmdEZnGdFdGeoZpdHZq dQdKZrGdLdMeoZsdNZtdOZudS)RzVClient for discovery based APIs. A client library for Google's discovery based APIs. )absolute_importz$jcgregorio@google.com (Joe Gregorio))buildbuild_from_documentfix_method_name key2param) OrderedDictN)BytesGenerator) MIMEMultipart)MIMENonMultipart)MutualTLSChannelError)mtls)service_account)universeTF)_auth mimeparse)_add_query_parameter positional) HttpErrorInvalidJsonErrorMediaUploadSizeErrorUnacceptableMimeTypeErrorUnknownApiNameOrVersionUnknownFileType)BatchHttpRequestHttpMockHttpMockSequence HttpRequestMediaFileUpload MediaUpload build_http) JsonModel MediaModelRawModel)Schemasz{[^}]*}z[a-zA-Z0-9_-]+zDhttps://www.googleapis.com/discovery/v1/apis/{api}/{apiVersion}/restzAhttps://{api}.googleapis.com/$discovery/rest?version={apiVersion}z)A description of how to use this function)PUTPOSTPATCH ()KBMBGBTBzThe request body.object) descriptiontypezOThe filename of the media request body, or an instance of a MediaUpload object.string)r2r3requiredzPThe MIME type of the media request body, or an instance of a MediaUpload object.) pageToken nextPageToken!GOOGLE_API_USE_CLIENT_CERTIFICATEGOOGLE_API_USE_MTLS_ENDPOINTGOOGLE_CLOUD_UNIVERSE_DOMAINzgoogleapis.com)traceppuseripstrictquery)r3locationceZdZfdZxZS)APICoreVersionErrorcNd}t|dS)NzIgoogle-api-core >= 2.18.0 is required to use the universe domain feature.)super__init__)selfmessage __class__s MC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\googleapiclient/discovery.pyrEzAPICoreVersionError.__init__s+ W  !!!!!)__name__ __module__ __qualname__rE __classcell__)rHs@rIrBrBs8"""""""""rJrBbodyceZdZejZdS)_BytesGeneratorN)rKrLrMr write _write_linesrJrIrQrQs!'LLLrJrQc|dddd}tj|s |tvr|dzS|S)zFix method names to avoid '$' characters and reserved word conflicts. Args: name: string, method name. Returns: The name with '_' appended if the name is a reserved word and '$' and '-' replaced with '_'. $_-)replacekeyword iskeywordRESERVED_WORDS)names rIrrsS <<S ! ! ) )#s 3 3D$."8"8cz rJc4g}t|}|ds|d|D]A}|r||,|dBd|S)zConverts key names into parameter names. For example, converting "max-results" -> "max_results" Args: key: string, the method key name. Returns: A safe method name based on the key name. rxrW)listisalphaappendisalnumjoin)keyresultcs rIrrsF s))C q6>>   c  99;;  MM!     MM#     776??rJc||d}||d}nd}|t}n|}d}t||D]~}tj||} t |||||| || | }t |||||||| | | | }n3#t $r&}|jjtj krYd}~u|d}~wwxYw|| |td|d||S) a)Construct 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: googleapiclient.Model, converts to and from the wire format. requestBuilder: googleapiclient.http.HttpRequest, encapsulator for an HTTP request. credentials: oauth2client.Credentials or google.auth.credentials.Credentials, credentials to be used for authentication. cache_discovery: Boolean, whether or not to cache the discovery doc. cache: googleapiclient.discovery_cache.base.CacheBase, an optional cache object for the discovery documents. client_options: Mapping object or google.api_core.client_options, client options to set user options on the client. (1) The API endpoint should be set through client_options. If API endpoint is not set, `GOOGLE_API_USE_MTLS_ENDPOINT` environment variable can be used to control which endpoint to use. (2) client_cert_source is not supported, client cert should be provided using client_encrypted_cert_source instead. In order to use the provided client cert, `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true`. More details on the environment variables are here: https://google.aip.dev/auth/4114 adc_cert_path: str, client certificate file path to save the application default client certificate for mTLS. This field is required if you want to use the default client certificate. `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true` in order to use this field, otherwise this field doesn't nothing. More details on the environment variables are here: https://google.aip.dev/auth/4114 adc_key_path: str, client encrypted private key file path to save the application default client encrypted private key for mTLS. This field is required if you want to use the default client certificate. `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true` in order to use this field, otherwise this field doesn't nothing. More details on the environment variables are here: https://google.aip.dev/auth/4114 num_retries: Integer, number of times to retry discovery with randomized exponential backoff in case of intermittent/connection issues. static_discovery: Boolean, whether or not to use the static discovery docs included in the library. The default value for `static_discovery` depends on the value of `discoveryServiceUrl`. `static_discovery` will default to `True` when `discoveryServiceUrl` is also not provided, otherwise it will default to `False`. always_use_jwt_access: Boolean, whether always use self signed JWT for service account credentials. This only applies to google.oauth2.service_account.Credentials. Returns: A Resource object with methods for interacting with the service. Raises: google.auth.exceptions.MutualTLSChannelError: if there are any problems setting up mutual TLS channel. )api apiVersionNTF) num_retriesstatic_discovery) basehttp developerKeymodelrequestBuilder credentialsclient_options adc_cert_path adc_key_pathalways_use_jwt_accessname: version: ) r _discovery_service_uri_options uritemplateexpand_retrieve_discovery_docrrrespstatus http_client NOT_FOUNDcloser) serviceNameversionrpdiscoveryServiceUrlrqrrrsrtcache_discoverycacherurvrwrmrnrxparamsdiscovery_httpservice discovery_url requested_urlcontentes rIrrsgn! 8 8F  &#  $  |#G78KWUU!! #*=&AA  -'!1   G*")-'-+)&;   G E   v} 555   |%%gg&VWWWs 2B B0 B+)B++B0cp||gS|"tdtgSttgS)aZ Returns Discovery URIs to be used for attempting to build the API Resource. Args: discoveryServiceUrl: string, the Original Discovery Service URL preferred by the customer. version: string, API Version requested Returns: A list of URIs to be tried for the Service Discovery, in order. NzADiscovery V1 does not support empty versions. Defaulting to V2...)loggerwarningV2_DISCOVERY_URI DISCOVERY_URI)rrs rIr{r{ZsH&#$$ O   !!!/00rJc (ddlm} |r1|| }|r||} | r| S|r/| ||} | r| St d|d||} dt jvr!t|dt jd} |rt|d|} t d | t|tj | } | | \} } | d } n#t$rYnwxYw t!j| }n=#t$$r0}td | zt)d}~wwxYw|r|r||| | S) aRetrieves the discovery_doc from cache or the internet. Args: url: string, the URL of the discovery document. http: httplib2.Http, An instance of httplib2.Http or something that acts like it through which HTTP requests will be made. cache_discovery: Boolean, whether or not to cache the discovery doc. serviceName: string, name of the service. version: string, the version of the service. cache: googleapiclient.discovery_cache.base.Cache, an optional cache object for the discovery documents. developerKey: string, Key for controlling API usage, generated from the API Console. num_retries: Integer, number of times to retry discovery with randomized exponential backoff in case of intermittent/connection issues. static_discovery: Boolean, whether or not to use the static discovery docs included in the library. Returns: A unicode string representation of the discovery document. r%)discovery_cacheNryrz REMOTE_ADDRuserIprfzURL being requested: GET %s)rmutf-8zFailed to parse as JSON: )r`r autodetectgetget_static_docrosenvironrrdebugr null_postprocexecutedecodeAttributeErrorjsonloads ValueErrorerrorrset)urlrprrrrrqrmrnrr actual_urlreqrrrs rIr~r~ts@"!!!!! =#..00E  iinnG !00gFF  N))+6;;@ J  "")#xM9RSS D)#ulCC  LL. ;;; dK5z B BCKKKK88MD' ..))      !*W%% !!! 07:;;;   ! 5  #w Ns*?D D"!D"&D;; E5+E00E5cfts%t|dd}|r|tkr tdSdSdS)Nuniverse_domain) HAS_UNIVERSEgetattrDEFAULT_UNIVERSErB)rtcredentials_universes rI4_check_api_core_compatible_with_credentials_universersQ &&{4EtLL  &$8 |#tjj}t |t jjr$tjj|}|9|df|j dfg} | D])\} }| "td |*t |trtj|}nrt{j?| | }|rP|\}}}tr!t |tjAr|jBn|}|C||d|d|vr|r|j$st,j|d|d}t5jtd}|dvrtud|dks|dkr8|r6t2r-|t:j!krtudt:j!d|}n tE|dd}ta||'|'dg}td|v}t||||||||| S)!a Create 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 or object, the JSON discovery document describing the API. The value passed in may either be the JSON string or the deserialized JSON. base: string, base URI for all HTTP requests, usually the discovery URI. This parameter is no longer used as rootUrl and servicePath are included within the discovery document. (deprecated) 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. credentials: oauth2client.Credentials or google.auth.credentials.Credentials, credentials to be used for authentication. client_options: Mapping object or google.api_core.client_options, client options to set user options on the client. (1) The API endpoint should be set through client_options. If API endpoint is not set, `GOOGLE_API_USE_MTLS_ENDPOINT` environment variable can be used to control which endpoint to use. (2) client_cert_source is not supported, client cert should be provided using client_encrypted_cert_source instead. In order to use the provided client cert, `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true`. More details on the environment variables are here: https://google.aip.dev/auth/4114 adc_cert_path: str, client certificate file path to save the application default client certificate for mTLS. This field is required if you want to use the default client certificate. `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true` in order to use this field, otherwise this field doesn't nothing. More details on the environment variables are here: https://google.aip.dev/auth/4114 adc_key_path: str, client encrypted private key file path to save the application default client encrypted private key for mTLS. This field is required if you want to use the default client certificate. `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true` in order to use this field, otherwise this field doesn't nothing. More details on the environment variables are here: https://google.aip.dev/auth/4114 always_use_jwt_access: Boolean, whether always use self signed JWT for service account credentials. This only applies to google.oauth2.service_account.Credentials. Returns: A Resource object with methods for interacting with the service. Raises: google.auth.exceptions.MutualTLSChannelError: if there are any problems setting up mutual TLS channel. Nrtzclient_options.credentials_filez,Arguments http and {} are mutually exclusiverrootUrlzYou are using HttpMock or HttpMockSequence withouthaving the service discovery doc in cache. Try calling build() without mocking once first to populate the cache. servicePathrauthoauth2scopeszGclient_options.credentials_file and credentials are mutually exclusive.)rquota_project_idwith_always_use_jwt_accessfalse)truerzQUnsupported GOOGLE_API_USE_CLIENT_CERTIFICATE value. Accepted values: true, falseziClientOptions.client_cert_source is not supported, please use ClientOptions.client_encrypted_cert_source.rclient_encrypted_cert_sourcer` mtlsRootUrlauto)neverralwayszTUnsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, alwaysrz1mTLS is not supported in any universe other than .features dataWrapper rpbaseUrlrrrqrs resourceDescrootDescschemar)Ggoogleapi_coreru ClientOptions isinstance collectionsabcMapping from_dictcredentials_filerformatstrrrbytesrrrrrrurllibparseurljoinrrgetenvr:rdetermine_domainrrYrrrB api_endpointr$rarkeys exceptionsDuplicateCredentialArgsrcredentials_from_filerrdefault_credentialsr with_scopesr Credentialshasattrr_create_self_signed_jwtauthorized_httpr r8r client_cert_sourcerr has_default_client_cert_source$default_client_encrypted_cert_sourcegoogle_auth_httplib2AuthorizedHttprpadd_certificater9r!Resource)rrofuturerprqrrrsrtrurvrwrxbanned_optionsoptionr]runiverse_domain_envclient_universeaudience_for_self_signed_jwtrrclient_cert_to_useuse_client_cert cert_pathkey_path passphrase http_channel mtls_endpointuse_mtls_endpointhttp_credentialsrs rIrrszV7EEGG.+/"9::R7AA.QQ - (  ,.O P +  LFD! BII$OO" '36*W%% GU # #6*W^^G4455Jth@P5Q$R$R         <   2GM4J K KDO & i(DdKK"3  *,?  ||H5GG!.2CTJJ  &% %#' "+* W  F  | KK # # ' '" 5 5 9 9(B G G L L N N    E, E. ; o0HH]. #9"3)0%3%D "#7)0%3%D A M M M"( E#/ VDD  N;(CDD N& N35QRR  N &@@AVWWK  / /0L M M M  (55DD <M!# *F O O $(CCC+j !H,,!V++0B+Ox7P$P$P/hHLehhh%#4==<=MNNN };;z2..-8344  !%'    rJcB|dkrQt|tdks t|tdkr|St|S|dkrtt|S|dkrtt|S|dkr.tt |St|tdks t|tdkr|St|S)afConvert 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. r4r`integernumberboolean)r3rintfloatboollower)value schema_types rI_castrsh ;;$r(( " "d5kkT"XX&=&=Lu::   ! !3u::  5<<    ! !4;;%%''' ;;$r(( " "d5kkT"XX&=&=Lu:: rJct|dkrdS|dd}t|}|t |dd|zSt |S)zConvert 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. rirN)lenupper_MEDIA_SIZE_BIT_SHIFTSrr)maxSizeunits bit_shifts rI_media_size_to_longrss 7||aq BCCL   E&**511I73B3<  I--7||rJc,d|d|d|dzS)aCreates an absolute media path URL. Constructed using the API root URI and service path from the discovery document and the relative path for the API method. Args: root_desc: Dictionary; the entire original deserialized discovery document. path_url: String; the relative URL for the API method. Relative to the API root, which is specified in the discovery document. Returns: String; the absolute URI for media upload for the API method. z'%(root)supload/%(service_path)s%(path)srr)root service_pathpathrT) root_descpath_urls rI_media_path_url_from_infors. 5)$!-088 rJcp|di}|diD] \}}|||< tD]}t||<|t vr=d|vr9t}||d||d<|S)a#Updates parameters of an API method with values specific to this library. Specifically, adds whatever global parameters are specified by the API to the parameters for the individual method. Also adds parameters which don't appear in the discovery document, but are available to all discovery based APIs (these are listed in STACK_QUERY_PARAMETERS). SIDE EFFECTS: This updates the parameters dictionary object in the method description. Args: method_desc: Dictionary with metadata describing an API method. Value comes from the dictionary of methods stored in the 'methods' key in the deserialized discovery document. root_desc: Dictionary; the entire original deserialized discovery document. http_method: String; the HTTP method used to call the API method described in method_desc. schema: Object, mapping of schema names to schema descriptions. Returns: The updated Dictionary stored in the 'parameters' key of the method description dictionary. parametersrequestrO) setdefaultritemsSTACK_QUERY_PARAMETERS#STACK_QUERY_PARAMETER_DEFAULT_VALUEcopyHTTP_PAYLOAD_METHODSBODY_PARAMETER_DEFAULT_VALUEupdate) method_descr http_methodrrr]r2rOs rI_fix_up_parametersr$&s0'' b99J']]<<<BBDD''k& 4'FF>CCEE 4***yK/G/G+0022 K *+++! 6 rJcB|di}|dg}t|dd}d}|rHt||}t|d<t |d<|||fS)aAdds 'media_body' and 'media_mime_type' parameters if supported by method. SIDE EFFECTS: If there is a 'mediaUpload' in the method description, adds 'media_upload' key to parameters. Args: method_desc: Dictionary with metadata describing an API method. Value comes from the dictionary of methods stored in the 'methods' key in the deserialized discovery document. root_desc: Dictionary; the entire original deserialized discovery document. path_url: String; the relative URL for the API method. Relative to the API root, which is specified in the discovery document. parameters: A dictionary describing method parameters for method described in method_desc. Returns: Triple (accept, max_size, media_path_url) where: - accept is a list of strings representing what content types are accepted for media upload. Defaults to empty list if not in the discovery document. - max_size is a long representing the max size in bytes allowed for a media upload. Defaults to 0L if not in the discovery document. - media_path_url is a String; the absolute URI for media upload for the API method. Constructed using the API root URI and service path from the discovery document and the relative path for the API method. If media upload is not supported, this is None. mediaUploadacceptr r`N media_bodymedia_mime_type)rrr"MEDIA_BODY_PARAMETER_DEFAULT_VALUEr'MEDIA_MIME_TYPE_PARAMETER_DEFAULT_VALUE)r"rrr media_uploadr'max_sizemedia_path_urls rI_fix_up_media_uploadr/Rs8??="55L   h + +F"<#3#3Ir#B#BCCHNW29hGG#E#J#J#L#L < (O(T(T(V(V $% 8^ ++rJc|d}|d}|d}t||||}t||||\}}} |||||| fS)aUpdates a method description in a discovery document. SIDE EFFECTS: Changes the parameters dictionary in the method description with extra parameters which are used locally. Args: method_desc: Dictionary with metadata describing an API method. Value comes from the dictionary of methods stored in the 'methods' key in the deserialized discovery document. root_desc: Dictionary; the entire original deserialized discovery document. schema: Object, mapping of schema names to schema descriptions. Returns: Tuple (path_url, http_method, method_id, accept, max_size, media_path_url) where: - path_url is a String; the relative URL for the API method. Relative to the API root, which is specified in the discovery document. - http_method is a String; the HTTP method used to call the API method described in the method description. - method_id is a String; the name of the RPC method associated with the API method, and is in the method description in the 'id' key. - accept is a list of strings representing what content types are accepted for media upload. Defaults to empty list if not in the discovery document. - max_size is a long representing the max size in bytes allowed for a media upload. Defaults to 0L if not in the discovery document. - media_path_url is a String; the absolute URI for media upload for the API method. Constructed using the API root URI and service path from the discovery document and the relative path for the API method. If media upload is not supported, this is None. r httpMethodid)r$r/) r"rrrr# method_idrr'r-r.s rI_fix_up_method_descriptionr4{sl@6"Hl+KD!I#KKPPJ(<Y*(($FHn [)VX~ MMrJctj|}tj|}|j|jkr|Stj||jS)a Update the media upload base url if its netloc doesn't match base url netloc. This can happen in case the base url was overridden by client_options.api_endpoint. Args: media_path_url: String; the absolute URI for media upload. base_url: string, base URL for the API. All requests are relative to this URI. Returns: String; the absolute URI for media upload. )netloc)rrurlparser6 urlunparse_replace)r.base_urlparsed_media_urlparsed_base_urls rI_fix_up_media_path_base_urlr=sw|,,^<<l++H55O/"888 < " "!!)?!@@  rJc|ds|dr tj||S|dr|n|dz}|dr |ddn|}||zS)z8Custom urljoin replacement supporting : before / in url.zhttp://zhttps:///r%N) startswithrrrendswith)rornew_basenew_urls rI_urljoinrDs ~~i  /CNN:$>$>/|##D#...}}S))9tttczH,,5c!""gg#G g rJceZdZdZdZdZdS)ResourceMethodParametersa-Represents the parameters associated with a method. Attributes: argmap: Map from method parameter name (string) to query parameter name (string). required_params: List of required parameters (represented by parameter name as string). repeated_params: List of repeated parameters (represented by parameter name as string). pattern_params: Map from method parameter name (string) to regular expression (as a string). If the pattern is set for a parameter, the value for that parameter must match the regular expression. query_params: List of parameters (represented by parameter name as string) that will be used in the query string. path_params: Set of parameters (represented by parameter name as string) that will be used in the base URL path. param_types: Map from method parameter name (string) to parameter type. Type can be any valid JSON schema type; valid values are 'any', 'array', 'boolean', 'integer', 'number', 'object', or 'string'. Reference: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1 enum_params: Map from method parameter name (string) to list of strings, where each list of strings is the list of acceptable enum values. ci|_g|_g|_i|_g|_t |_i|_i|_| |dS)a]Constructor for ResourceMethodParameters. Sets default values and defers to set_parameters to populate. Args: method_desc: Dictionary with metadata describing an API method. Value comes from the dictionary of methods stored in the 'methods' key in the deserialized discovery document. N) argmaprequired_paramsrepeated_paramspattern_params query_paramsr path_params param_types enum_paramsset_parameters)rFr"s rIrEz!ResourceMethodParameters.__init__sc !! 55 K(((((rJc|di}tt|}|D]K\}}t |}||j|<|dr|d|j|<|dr|d|j|<|dr|j ||dr|j ||ddkr|j ||ddkr|j ||d d |j|<Mt|dD]}t"|d D]a}t |d } |j | | |j vr|j | bd S) aPopulates maps and lists based on method description. Iterates through each parameter for the method and parses the values from the parameter dictionary. Args: method_desc: Dictionary with metadata describing an API method. Value comes from the dictionary of methods stored in the 'methods' key in the deserialized discovery document. rpatternenumr5repeatedr@r?rr3r4rN)rrsortedrrrHrKrOrIrcrJrLrMaddrN URITEMPLATEfinditerVARNAMEgroupremove) rFr"rsorted_parametersargdescparammatch namematchr]s rIrPz'ResourceMethodParameters.set_parameterss;!__\266 'z/?/?/A/A(B(BCC*0022 A AICcNNE!$DK xx "" =-1)_#E*xx 7*.v, 'xx ## 3$++E222xx ## 3$++E222xx ##w..!((///xx ##v-- $$U+++&*hhvx&@&@D U # # !))+f*=>> 3 3E$--ekk!nn== 3 3  !3!344 $$T***4,,,%,,T222  3 3 3rJN)rKrLrM__doc__rErPrTrJrIrFrFs<0))).'3'3'3'3'3rJrFctt|\tf d}dtdg}t jdkr|dt|di }| ttj }ddgD}d |vr|d t|D]} | |vr|| |D]B} | |vrd } | j vrd } d } | jvrd } dj| } | dd }d| vr=|d| d|| | d| dd n9| dd}|d| d|d|| | d | dg}| dg}|rI|rG|dt!||D]!\} }|d| d|d"Ddvrndr|dnC|d|dt'|d d ||fS)!aeCreates a method for attaching to a Resource. Args: 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. schema: object, mapping of schema names to schema descriptions. c $ "||D]-}|*jvr"td|.t |}|D] }||||=*jD]?}||vr9|tvstt',drtd|z@*j D]i\}}||vr`t||tr ||g}n||}|D]0}tj||td|d|d|d1j*j D]n\}}||vre|*jvr$t||ts ||}n ||g}|D],} | |vr&td|d| dt|d-oi} i} | D]\} } *j| d "| *jvr/t)| t)gkr"fd | D} nt+| "} | *jvr| | *j| <| *jvr| | *j| <|d d}|d d}|d d}|jr |j| d<|j})drt7}nd'vrt9}'dd}i}||| | ||\}}}}t=j+|}tA|j!||z}d}d}|rTt|tr|2tD#d|tIj%|\}}|tM|tOj(|gd)#stU|tW||}n't|tXr|}ntd|-4|-%cxkrdkrnnt]d%zt=j&|}tA|j!||z}t_||j!}|0rtc|dd}|0r|}n|R|2|d<|3d|-}tc|dd}nntid}tk|ddtm|d7d}|8||9|tm|27d}d |d!<|3d|-}|8||9|tuj;} ty| d"#}!|!=|d"$| >}|?}d%|z|d<tc|dd&}tD@d'$d(||A|jB|jC|$||(|)S)*Nz%Got an unexpected keyword argument {}responsezMissing required parameter "%s"z Parameter "z " value "z" does not match the pattern ""z" is not an allowed value in "r4c0g|]}t|SrT)r).0r_to_types rI z0createMethod..method..s#???AeAw//???rJrOr(r)rf_mediarlr`zDmedia_mime_type argument not specified: trying to auto-detect for %s,)mimetypez*media_filename must be str or MediaUpload.rzMedia larger than: %s uploadType resumablez content-typemediarelated_write_headerscdSNrTrFs rIz.createMethod..method..sDrJr?binaryzContent-Transfer-EncodingF) mangle_from_)unixfromz multipart/related; boundary="%s" multipartzURL being requested:  )methodrOheadersmethodIdro)D_validate_credentialsrH TypeErrorrrarrI_PAGE_TOKEN_NAMES_findPageTokenName_methodPropertiesrKrrrrer`rOrJrNrr3rrLrM _developerKey_modelrAr"r#rr|r}rD_baseUrlrr mimetypes guess_typerr best_matchrerrrsizerr=rorrmgetbytesr setattrr split set_payloadattachioBytesIOrQflattengetvalue get_boundaryr_requestBuilder_httpre)-rFkwargsr]rregexpvaluespvalueenumsvaluesractual_query_paramsactual_path_paramsrf cast_value body_valuemedia_filenamer)rr api_versionr}rr?rO expanded_urlrromultipart_boundaryrWr,msgRootmsgpayloadfpgrir'r1r  mediaPathUrl methodDescr~ methodNamerpathUrlrs- @rIr|zcreateMethod..methodCs ""$$$ V VD:,,, G N Nt T TUUU-FKKMM"" ! !Dd|#4L. N ND6!!0004F%j&*EE550$$E$LMMM%4::<<  KD%v~~fTlC00+%d|nGG$TlG%Fxv..6'i#ttVVVUUU47 &17799  KD%v~~:555j4L#??5$D\FF$Tl^F#EE))'i#ttUUUCJJJJ8* ! ,,.. H HJC ,00h??Gj000T%[[DHH5L5L??????? "5'22 j--->H#J$5c$:;j,,,=G":#4S#9:ZZ-- L$77 **%6==   <)-);  &    x ( ( LLEE z ) )JJE nn\488 ',}} ')??C-c4=AAC%%'' K*3 kJJ%%''( O) <.:.C.C.E.EGN+'00L4E4E4G4GHHD.sL'JJCC,I66GG%57H7HIII+GN,C,I,I#,N,NOCOOD)))NN3'''+L,A,A,C,C,I,I#,N,NOC7?C34*33A|7H7H7J7JKKGOOG,,,NN3'''B'???AIIgI666;;==D)0)=)=)?)?&=*/+GN+/sL+NNC ZZZEFFF## J N $   rJr2z rzArgs: rc,g|]}t|SrT)r)rhss rIrjz createMethod..sOOOQIaLLOOOrJparameterOrderrOr`z (repeated)z (required)z A parameter$refz z : object, z$ The object takes the form of: r3r4z: z,  rSenumDescriptionsz Allowed values z z - rerkz/ Returns: The media object as a string. z( Returns: An object of the form: rb)rr4rFrDEFAULT_METHOD_DOCr rHrcrarextendrrUrJrIprettyPrintByNameziprAprettyPrintSchemarre)rrrrr|docsskip_parametersall_args args_orderedr]r]rTr5 paramdescparamdoc paramtyperSenumDescr^r'r1r rr~rrs`` ` @@@@@@@rI createMethodr-s!,,J #:x@@**55Jq q q q q q q q q q q q q q f NN=*< = =v FD : !! I8<< b99>>@@AAO1222J%**,,--HOO*..9I2*N*NOOOLF###x  && | # #    % % %!>!> / ! !  *, , ,$H *, , ,$H|,Z->s-CD == >> Y   KKKCCHHHH,,Yv->????     " fh77I KKK(+YYY((HHHU   }}VR((==!3R88  >H > KK. / / / #D( 3 3 > > t ttt<====Z   x ( ( J KKM N N N N KKF G G G KK00J1GHH I I I FIrwwt}}---  rJr6r7c@tfd}|fS)aCreates any _next methods for attaching to a Resource. The _next methods allow for easy iteration through list() responses. Args: methodName: string, name of the method to use. pageTokenName: string, name of request page token field. nextPageTokenName: string, name of response page token field. isPageTokenParameter: Boolean, True if request page token is a query parameter, False if request page token is a field of the request body. c| d}|sdStj|}rAt|j ||_tdd|jn|j}||j}|| <| ||_t|j|_ d|j vr|j d=tdd||S)aRetrieves the next page of results. Args: previous_request: The request for the previous page. (required) previous_response: The response from the request for the previous page. (required) Returns: A request object that you can call 'execute()' on to request the next page. Returns None if there are no more items in the collection. NzNext page request URL: r{zcontent-lengthzNext page request body: ) rrrurirrr deserializerO serializer  body_sizer}) rFprevious_requestprevious_responser7rrrrOisPageTokenParameterrnextPageTokenName pageTokenNames rI methodNextz$createNextMethod..methodNextIs *--.?FF  4),--  O. ]MGK LLL:::w{{S T T T TKE$$W\22D"/D  ??400GL #GL 1 1G 7?22O$45 LLLJJJM N N NrJ)r)rrrrrs```` rIcreateNextMethodr6sK"!,,J%%%%%%%%N  ##rJcpeZdZdZerejndfdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdS)rz(A class for interacting with a resource.r`c g|_||_||_||_||_||_||_||_||_| |_ d|_ | dS)aBuild 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: googleapiclient.Model, converts to and from the wire format. requestBuilder: class or callable that instantiates an googleapiclient.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. universe_domain: string, the universe for the API. The default universe is "googleapis.com". FN) _dynamic_attrsrrrrr _resourceDesc _rootDesc_schema_universe_domain_credentials_validated_set_service_methods) rFrprrrrsrqrrrrs rIrEzResource.__init__vso>!   )-)! /&+# !!#####rJcN|j|||j|<dS)zSets an instance attribute and tracks it in a list of dynamic attributes. Args: attr_name: string; The name of the attribute to be set value: The value being set on the object and tracked in the dynamic cache. N)rrc__dict__)rF attr_namers rI_set_dynamic_attrzResource._set_dynamic_attrs- ""9---#( i   rJcXtj|j}|jD]}||=|d=|S)zTrim the state down to something that can be pickled. Uses the fact that the instance variable _dynamic_attrs holds attrs that will be wiped and restored on pickle serialization. r)rrr)rF state_dict dynamic_attrs rI __getstate__zResource.__getstate__sA Yt}--  / ) )L<(( ' (rJcp|j|g|_|dS)zReconstitute the state of the object from being pickled. Uses the fact that the instance variable _dynamic_attrs holds attrs that will be wiped and restored on pickle serialization. N)rr!rr)rFstates rI __setstate__zResource.__setstate__s: U###  !!#####rJc|SrtrTrus rI __enter__zResource.__enter__s rJc.|dSrt)r)rFexc_typeexcexc_tbs rI__exit__zResource.__exit__s rJc8|jdS)zClose httplib2 connections.N)rrrus rIrzResource.closes rJc||j|j|j||j|j|j||j|jdSrt)_add_basic_methodsrrr_add_nested_resources_add_next_methodsrus rIrzResource._set_service_methodssa  2DNDLQQQ ""4#5t~t|TTT t14<@@@@@rJc ||kr<|d|dd d fd }|d|d|vr|dD]\}}t||||\}}|||||j|ddrGt|d z|||\}}|||||jdSdS) Nr batchPathbatchc&t|S)aCreate a BatchHttpRequest object based on the discovery document. Args: callback: callable, A callback to be called for each response, of the form callback(id, response, exception). The first parameter is the request id, and the second is the deserialized response object. The third is an apiclient.errors.HttpError exception object if an HTTP error occurred while processing the request, or None if no error occurred. Returns: A BatchHttpRequest object based on the discovery document. callback batch_uri)rrs rInew_batch_http_requestz;Resource._add_basic_methods..new_batch_http_requests(YOOOOrJrmethodssupportsMediaDownloadFrkrt)rrrr__get__rH) rFrrrrrrfixedMethodNamer|rs @rIrzResource._add_basic_methodssm 8 # ### ['222I  P P P P P P  " "#;=S T T T  $ $*6y*A*G*G*I*I  & J*6 Hf++'&&#V^^D$.%I%I >>"95AA.:"X-z8V//+OV**'dn)M)M % $  rJcd|vrdfd}|dD]E\}}|||\}}|||||jDdSdS)N resourcesc~t|}fd}t|ddt|dd||fS)a&Create a method on the Resource to access a nested Resource. Args: methodName: string, name of the method to use. methodDesc: object, fragment of deserialized discovery document that describes the method. c pt|j|j|j|j|j|j S)Nr)rrrrrrr)rFrrrs rImethodResourcezTResource._add_nested_resources..createResourceMethod..methodResourcesD#!Z $ "k%)%7'+';%/!)%(,(=    rJrbzA collection resource.__is_resource__T)rr)rrrrrs ` rIcreateResourceMethodz.createResourceMethodsi-Z88         3KLLL(94@@@"N33rJ)rrrrH) rFrrrrrrrr|s `` rIrzResource._add_nested_resourcess , & & 4 4 4 4 4 48+7{*C*I*I*K*K  & J*>*>z:*V*V'&&#V^^D$.%I%IA ' &<  rJcd|vrdS|dD]\}}tt||d}|s&d}t|di}|s d}tt||d}|spt |dz|||\}} ||| ||jdS)NrreTrFr_next)rrrrrrrrH) rFrrrrrrrrr|s rIrzResource._add_next_methods)s" L ( ( F&29&=&C&C&E&E   "J 2!*fjAA!! % #' .z~~lB/O/OPPM  ',$ 2%j&)DD!! ! &6W$!$ '' #OV  " "dn!E!E    +  rJct|jdd}tr!|jpt j|j|nd|_|jS)aValidates client's and credentials' universe domains are consistent. Returns: bool: True iff the configured universe domain is valid. Raises: UniverseMismatchError: If the configured universe domain is not valid. rtNT)rrrrrcompare_domainsr)rFrts rIrzResource._validate_credentialsHsYdj->>   +P+D,A;OO #**rJN)rKrLrMrbrrrrErrrrrrrrrrrrTrJrIrrss226BI11r,$,$,$,$\)))   $$$AAA +++Z$$$L>+++++rJrcFtfdtDdS)zSearch field names for one like a page token. Args: fields: container of string, names of fields. Returns: First name that is either 'pageToken' or 'nextPageToken' if one exists, otherwise None. c3$K|] }|v|V dSrtrT)rh tokenNamefieldss rI z%_findPageTokenName..is-MMyf9L9L9L9L9L9LMMrJN)nextr)r s`rIrr^s1 MMMM$5MMMt  rJc||i}d|vr||di}|diS)aGet properties of a field in a method description. Args: methodDesc: object, fragment of deserialized discovery document that describes the method. schema: object, mapping of schema names to schema descriptions. name: string, name of top-level field in method description. Returns: Object representing fragment of deserialized discovery document corresponding to 'properties' field of object corresponding to named field in method description, if it exists, otherwise empty dict. r properties)r)rrr]r^s rIrrmsK >>$ # #D ~~zz$v,++ 88L" % %%rJ)NNr%T)r6r7T)vrb __future__r __author____all__rrcollections.abcremail.generatorr email.mime.multipartr email.mime.nonmultipartr http.clientclientrrrrZloggingrrrrgoogle.api_core.client_optionsrgoogle.auth.exceptionsr google.auth.transportr google.oauth2rhttplib2r|r ImportErrorgoogle.api_corerrgoogleapiclientrrgoogleapiclient._helpersrrgoogleapiclient.errorsrrrrrrgoogleapiclient.httprrrrrrr googleapiclient.modelr!r"r#googleapiclient.schemar$RETRIES getLoggerrKrcompilerWrYrV1_DISCOVERY_URIrr frozensetrr r r*r+rr8r9r:rrrrrBr\rQrrrr{r~rrrrrr$r/r4r=rDr1rFrrrrrrTrJrIr+s'&&&&& 3 J J J###### ******......444444!!!!!!  %%%%888888&&&&&&))))))     ((((((LLLLL-,,,,,,,EEEEEEEEBAAAAAAAAA******  8 $ $bj## "*% & &M!JA y!9!9!9:: ""BbAA/BHUU #  &&" #  ++'3%H!==###F#F#FGG/7W&M&M#"""""*"""F8$$(((((n((("0 A   !VVVVr111@ QQQQh&&& A    LLLL^>&*)))X&,&,&,R,N,N,N^.$W3W3W3W3W3vW3W3W3tF F F V% :$:$:$:$zh+h+h+h+h+vh+h+h+V   &&&&&s$4A99BBBBB