
    9i[                     z   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSKJ
r
  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  \R8                  (       a  SSKJr  OSSKJr  \R@                  " \!5      r" " S S\	RF                  5      r$g)zh
This module provides a client class for CFC.
API Reference: https://cloud.baidu.com/doc/CFC/index.html
    N)bce_base_client)utils)bce_v1_signer)bce_http_client)handler)http_content_types)http_headers)http_methods)cfc_handler)models)BceClientError)BceServerError)required)compat)quotec                   T   \ rS rSrSrSrSS jr  S S jr  S S jr    S!S jr	  S"S	 jr
S#S
 jrS#S jr  S$S jrS#S jr   S"S jrS%S jrS#S jr  S$S jr  S$S jrSS jr  S%S jrSS jrSS jrS%S jrS#S jrSS jr\S 5       r\S 5       r   S&S jr S'S jrSr g)(	CfcClient2   z
CdnClient
z/v1Nc                 B    [         R                  R                  X5        g N)r   BceBaseClient__init__)selfconfigs     `/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/cfc/cfc_client.pyr   CfcClient.__init__8   s    %%..t<    c           	          0 nX'S'   X7S'   Ub  XWS'   Uc  0 nU R                  [        R                  SU-   S-   [        R                  " U5      UUSS9$ )C  
invoking function

:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param invocation_type: (required)  Event/RequestResponse/DryRun
:type invocation_type string

:param  log_type: None / Tail You can set this optional parameter to Tail in the request only if you
                 specify the InvocationType parameter with value RequestResponse. In this case,CFC
                 returns the base64-encoded last 4 KB of log data produced by your cfc function in
                 the x-bce-log-result header.
:type log_type string

:param qualifier Minimum length of 1. Maximum length of 128. You can use function versions or function aliases.
                 If you don't, the default is $LATEST.
:type qualifier string

:param body: json

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: httplib.httpresponse
invocationTypelogType	Qualifier/functions/z/invocationsT)bodyparamsr   special_send_requestr
   POSTjsondumps)r   function_nameinvocation_typelog_typer$   	qualifierr   r%   s           r   invocationsCfcClient.invocations;   su    B #2 $y "+;<D!!M)N:D!4 " ) 	)r   c                 (    U R                  XX4XV5      $ )r   )r0   )r   r,   r-   r.   r$   r/   r   s          r   invokeCfcClient.invokej   s    B PYbbr   c           
      L   Uc  0 nUUS.UUU
UUU	USU0S.	nU(       aJ  [        US5      nUR                  5       n[        R                  " U5      R	                  S5      nUUS   S'   OX~S   S'   0 nU R                  [        R                  S[        R                  " U5      UUS	9$ )
aq  
Create cfc function

:param function_name  (required)
:type function_name string

:param description - A short, user-defined function description. Minimum length of 0. Maximum length of 256.
:type description string

:param environment environment's configuration settings.
:type environment String to string map, [a-zA-Z]([a-zA-Z0-9_])+

:param handler  (required) Maximum length of 128. [^\s]+
:type handler string

:param memory_size  The amount of memory, in MB.The default value is 128 MB. The value must be a multiple of 64
                    MB. From 128M to 3008M. Now it only supports 128M.
:type memory_size int

:param region  bj or gz. Now it only supports bj.
:type region string

:param zip_file  (required)
:type zip_file bytes The contents of your zip file containing your deployment package.
                the contents of the zip file must be base64-encoded.

:param config: None
:type config: baidubce.BceClientConfiguration

:param publish  This boolean parameter can be used to request CFC to create the CFC function and publish
                a version as an atomic operation.
:type publish: boolean

:param run_time: python2 | nodejs6.11
:type run_time: string

:param timeout: 1-300 The default is 3 seconds.
:type timeout: int

:param code_zip_file: the file path of the zipped code.
:type code_zip_file: string

:return:
:rtype: baidubce.bce_response.BceResponse
)PublishDryRun	Variables)	CodeDescriptionRegionTimeoutFunctionNameHandlerRuntime
MemorySizeEnvironmentrbutf-8r9   ZipFilez
/functionsr$   r%   r   )
openreadbase64	b64encodedecoder(   r
   r)   r*   r+   )r   r,   descriptionenvironmentr   memory_sizeregionzip_filepublishrun_timetimeoutdry_runcode_zip_filer   data	code_filecodecode_base64r%   s                      r   create_functionCfcClient.create_function   s    b K #! ')%[
  ]D1I>>#D **4077@K&1DL#&.L#!!D! "  	r   c                     0 nUb  XS'   Ub  X'S'   Ub  X7S'   Ub  XGS'   Ub  XWS'   U R                  [        R                  S0 UUS9$ )aI  
List cfc function

:param function_version
:type function_version string

:param page
:type page int

:param page_size
:type page_size int

:param marker
:type marker int

:param max_items
:type max_items int

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
FunctionVersionpagepageSizeMarkerMaxItemsr#   rE   r(   r
   GET)r   function_versionr]   	page_sizemarker	max_itemsr   r%   s           r   list_functionsCfcClient.list_functions   s|    4 '(8$%!6N !*:%8 !*:!! "  	r   c                 \    0 nUb  X$S'   U R                  [        R                  SU-   0 UUS9$ )ai  
get function

:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param qualifier Minimum length of 1. Maximum length of 128. You can use function versions or function aliases.
                 If you don't, the default is $LATEST.
:type qualifier string

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r"   r#   rE   ra   r   r,   r/   r   r%   s        r   get_functionCfcClient.get_function  sI    *  "+;!!M) "  	r   c                 \    0 nUb  X$S'   U R                  [        R                  SU-   0 0 US9$ )al  
delete_function

:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param qualifier Minimum length of 1. Maximum length of 128. You can use function versions or function aliases.
                 If you don't, the default is $LATEST.
:type qualifier string

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r"   r#   rE   r(   r
   DELETErj   s        r   delete_functionCfcClient.delete_function*  sI    *  "+;!!M) "  	r   c                     0 nUb  X&S'   Ub  X6S'   Ub  XFS'   U R                  [        R                  SU-   S-   [        R                  " U5      0 US9$ )a  
update_function_code

:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param zip_file
:type zip_file bytes The contents of your zip file containing your deployment package.
                the contents of the zip file must be base64-encoded.
:param publish  This boolean parameter can be used to request CFC to create the CFC function and publish
                a version as an atomic operation.
:type publish: boolean

:param dry_run  This boolean parameter can be used to test your request to CFC to update the function and
                publish a version as an atomic operation. It will do all necessary computation and validation
                of your code but will not upload it or a publish a version. Each time this operation is invoked,
                the CodeSha256 hash value of the provided code will also be computed and returned in the
                response.
:type dry_run: boolean

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
rD   r6   r7   r#   z/coderE   r(   r
   PUTr*   r+   )r   r,   rO   rP   rS   r   r$   s          r   update_function_codeCfcClient.update_function_codeI  sq    @ &O%O$N!!M)G3D! "  	r   c                 b    0 nUb  X$S'   U R                  [        R                  SU-   S-   0 0 US9$ )av  
get_function_configuration
:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param qualifier Minimum length of 1. Maximum length of 128. You can use function versions or function aliases.
                 If you don't, the default is $LATEST.
:type qualifier string

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r"   r#   /configurationrE   ra   rj   s        r   get_function_configuration$CfcClient.get_function_configurationx  sO    (  "+;!!M),<< "  	r   c                     0 nUb  X(S'   Ub  SU0US'   Ub  XHS'   Ub  XXS'   Ub  XhS'   U R                  [        R                  SU-   S-   [        R                  " U5      0 US	9$ )
a  
update_function_configuration
:param function_name  (required)
:type function_name string

:param description - A short, user-defined function description. Minimum length of 0. Maximum length of 256.
:type description string

:param environment environment's configuration settings.
:type environment String to string map, [a-zA-Z]([a-zA-Z0-9_])+

:param handler  (required) Maximum length of 128. [^\s]+
:type handler string

:param run_time: python2 | nodejs6.11
:type run_time: string

:param timeout: 1-300 The default is 3 seconds.
:type timeout: int

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r:   r8   rA   r>   r?   r<   r#   rx   rE   rs   )	r   r,   rK   rL   r   rQ   rR   r   rU   s	            r   update_function_configuration'CfcClient.update_function_configuration  s    : ""-"#."<D%O&O%O!!M),<<D! "  	r   c                 p    0 nUb  X%S'   Ub  X5S'   U R                  [        R                  SU-   S-   0 UUS9$ )a  
list_versions_by_function
:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

        :param marker
:type marker int

:param max_items
:type max_items int

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r_   r`   r#   	/versionsrE   ra   )r   r,   re   rf   r   r%   s         r   list_versions_by_function#CfcClient.list_versions_by_function  s\    , %8 !*:!!M)K7 "  	r   c                 b    0 nUb  X$S'   U R                  [        R                  SU-   S-   0 UUS9$ )aN  
publish_version
:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param description  A short, user-defined function publish description. Minimum length of 0. Maximum length of
                    256.
:type description string

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r:   r#   r   rE   )r(   r
   r)   )r   r,   rK   r   r%   s        r   publish_versionCfcClient.publish_version  sN    ( "$/=!!!M)K7 "  	r   c                 ~    0 nUb  X&S'   Ub  X6S'   Ub  XFS'   U R                  [        R                  SU-   S-   0 UUS9$ )a&  
list_aliases
:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param function_version
:type function_version string

:param marker
:type marker int

:param max_items
:type max_items int

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r\   r_   r`   r#   /aliasesrE   ra   )r   r,   rc   re   rf   r   r%   s          r   list_aliasesCfcClient.list_aliases  sk    4 '(8$%%8 !*:!!M)J6 "  	r   c                     0 nUb  XFS'   Ub  X&S'   Ub  X6S'   U R                  [        R                  SU-   S-   [        R                  " U5      0 US9$ )a  
create_alias
:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param name alias name
:type name string

:param function_version function version for which you are creating the alias. (\$LATEST|[0-9]+)
:type function_version string

:param config: None
:type config: baidubce.BceClientConfiguration

:param description   Description of the alias.
:type description string

:return:
:rtype: baidubce.bce_response.BceResponse
r:   r\   Namer#   r   rE   r'   )r   r,   rc   namerK   r   rU   s          r   create_aliasCfcClient.create_alias0  ss    4 ""-'&6"#L!!M)J6D! "  	r   c                 V    U R                  [        R                  SU-   S-   U-   0 0 US9$ )a  
get_alias
:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param alias_name alias name
:type alias_name string

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r#   	/aliases/rE   ra   r   r,   
alias_namer   s       r   	get_aliasCfcClient.get_aliasY  s@    & !!M)K7*D "  	r   c                     0 nUb  XFS'   Ub  X6S'   U R                  [        R                  SU-   S-   U-   [        R                  " U5      0 US9$ )a  
update_alias
:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param alias_name alias name
:type alias_name string

:param function_version function version for which you are update the alias. (\$LATEST|[0-9]+)
:type function_version string

:param description   Description of the alias.
:type description string

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r:   r\   r#   r   rE   rs   )r   r,   r   rc   rK   r   rU   s          r   update_aliasCfcClient.update_aliass  sk    4 ""-'&6"#!!M)K7*DD! "  	r   c                 V    U R                  [        R                  SU-   S-   U-   0 0 US9$ )a  
delete_alias
:param function_name  (required) The cfc function name. You can specify a function name (function_name)
                        or you can specify Baidu Resource Name (BRN) of the function (for example,
                        brn:bce:cfc:bj:account-id:function:function_name). Cfc also allows you
                        to specify a simple BRN (for example, account_id:function_name). The length of BRN is
                        limited to 1 to 140 characters. The function name is limited to 64 characters in length.
:type function_name string

:param alias_name alias name
:type alias_name string

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r#   r   rE   rn   r   s       r   delete_aliasCfcClient.delete_alias  s@    & !!M)K7*D "  	r   c                 V    0 nUb  XS'   U R                  [        R                  S0 UUS9$ )a  
list_triggers
:param function_brn  (required) The cfc function brn.
:type function_brn string

:param config: None
:type config: baidubce.BceClientConfiguration

:return: message result as following format
    {
      "Relation": [
        {
          "RelationId": "brn:bce:cfc-http-trigger:bj:cd64f99c69d7c404b61de0a4f1865834:b8542048977633ad0a867aefc33fd32a/cfc/GET/cfc/docs",
          "Sid": "cfc-dfbd5359-1afb-49e7-81d7-16554056c79d",
          "Source": "cfc-http-trigger/v1/CFCAPI",
          "Target": "brn:bce:cfc:bj:cd64f99c69d7c404b61de0a4f1865834:function:helloCFCDocs:$LATEST",
          "Data": {
            "AuthType": "anonymous",
            "Brn": "brn:bce:cfc-http-trigger:bj:cd64f99c69d7c404b61de0a4f1865834:b8542048977633ad0a867aefc33fd32a/cfc/GET/cfc/docs",
            "EndpointPrefix": "https://6ewfn1337kndc.cfc-execute.bj.baidubce.com",
            "Method": "GET",
            "ResourcePath": "/cfc/docs"
          }
        },
        {
          "RelationId": "brn:bce:cfc-http-trigger:bj:cd64f99c69d7c404b61de0a4f1865834:b8542048977633ad0a867aefc33fd32a/cfc/POST,PUT/cfc/docs/edit",
          "Sid": "cfc-dfbd5359-1afb-49e7-81d7-16554056c79d",
          "Source": "cfc-http-trigger/v1/CFCAPI",
          "Target": "brn:bce:cfc:bj:cd64f99c69d7c404b61de0a4f1865834:function:helloCFCDocs:$LATEST",
          "Data": {
            "AuthType": "anonymous",
            "Brn": "brn:bce:cfc-http-trigger:bj:cd64f99c69d7c404b61de0a4f1865834:b8542048977633ad0a867aefc33fd32a/cfc/POST,PUT/cfc/docs/edit",
            "EndpointPrefix": "https://6ewfn1337kndc.cfc-execute.bj.baidubce.com",
            "Method": "POST,PUT",
            "ResourcePath": "/cfc/docs/edit"
          }
        }
      ]
    }
:rtype: baidubce.bce_response.BceResponse
FunctionBrn	/relationrE   ra   )r   function_brnr   r%   s       r   list_triggersCfcClient.list_triggers  sE    T #$0=!!! "  	r   c                 &   0 nUb  XS'   Ub  X%S'   UbJ  [        U[        R                  5      (       a'  UR                  5       US'   UR	                  5       US'   OX5S'   U R                  [        R                  S[        R                  " U5      0 US9$ )a  
create_trigger
:param function_brn  (required) The cfc function brn.
:type function_brn string

:param source. The trigger source type. For example, models.CRONTAB_TRIGGER
:type source string

:param trigger_data The trigger data. You can get details from
    https://cloud.baidu.com/doc/CFC/s/Kjwvz47o9/#relationconfiguration
:type trigger_data models.AbstractTriggerDateModel

:param config: None
:type config: baidubce.BceClientConfiguration

:return:  message result as following format
    {
        "Relation": {
            "Sid": "cfc-c53bef4e-2cac-4bc6-84c1-2d5ec2f8bec2",
            "RelationId" : "00457f0b-20d8-4f3d-8555-c2u121f38313",
            "Source": "string",
            "Target": "brn:bce:cfc:bj:640c8817bd1de2928d47256dd0620ce5:function:test:$LATEST",
            "Data": {
                "EventType":["PutObject", "PostObject"],
                "Prefix":"images/",
                "Suffix":".jpg",
                "Status":"enabled"
            }
        }
    }
:rtype: baidubce.bce_response.BceResponse
TargetSourceDatar   rE   )

isinstancer   AbstractTriggerDataModelget_trigger_source	serializer(   r
   r)   r*   r+   )r   r   sourcetrigger_datar   rU   s         r   create_triggerCfcClient.create_trigger  s    B #)N#N#,(G(GHH!-!@!@!BX+557V+V!!D! "  	r   c                 4   0 nUb  XS'   Ub  XFS'   UbJ  [        U[        R                  5      (       a'  UR                  5       US'   UR	                  5       US'   OX6S'   Ub  X&S'   U R                  [        R                  S[        R                  " U5      0 US9$ )a\  
create_trigger
:param function_brn  (required) The cfc function brn.
:type function_brn string

:param source  (required) The trigger source type. For example, models.CRONTAB_TRIGGER
:type source string

:param relation_id  (required) The relation_id.
:type relation_id string

:param trigger_data The trigger data. You can get details from
    https://cloud.baidu.com/doc/CFC/s/Kjwvz47o9/#relationconfiguration
:type trigger_data models.AbstractTriggerDateModel

:param config: None
:type config: baidubce.BceClientConfiguration

:return: message result as following format
    {
        "Relation": {
            "Sid": "cfc-c53bef4e-2cac-4bc6-84c1-2d5ec2f8bec2",
            "RelationId" : "00457f0b-20d8-4f3d-8555-c2u121f38313",
            "Source": "string",
            "Target": "brn:bce:cfc:bj:640c8817bd1de2928d47256dd0620ce5:function:test:$LATEST",
            "Data": {
                "EventType":["PutObject", "PostObject"],
                "Prefix":"images/",
                "Suffix":".jpg",
                "Status":"enabled"
            }
        }
    }
:rtype: baidubce.bce_response.BceResponse
r   r   r   
RelationIdr   rE   )
r   r   r   r   r   r(   r
   rt   r*   r+   )r   r   relation_idr   r   r   rU   s          r   update_triggerCfcClient.update_trigger  s    H #)N#N#,(G(GHH!-!@!@!BX+557V+V"!,!!D! "  	r   c                 r    0 nUb  XS'   Ub  X%S'   Ub  X5S'   U R                  [        R                  S0 UUS9$ )ai  
delete_trigger
:param function_brn  (required) The cfc function brn.
:type function_brn string

:param source  (required) The trigger source type.
:type source string

:param relation_id  (required) The relation_id.
:type relation_id string

:param config: None
:type config: baidubce.BceClientConfiguration

:return:
:rtype: baidubce.bce_response.BceResponse
r   r   r   r   rE   rn   )r   r   r   r   r   r%   s         r   delete_triggerCfcClient.delete_triggerT  s`    $ #+8%8"#.< !! "  	r   c                     g)N  )r   r,   s     r   _encode_function_nameCfcClient._encode_function_namet  s    r   c                     Uc  U R                   $ [        R                  " U R                   5      nUR                  U5        U$ r   )r   copymerge_non_none_values)r   r   
new_configs      r   _merge_configCfcClient._merge_configx  s7    >;;4;;/J,,V4r   c	                    U R                  X5      nUc  [        R                  nU=(       d    0 n[        R                  U[
        R                  '   UR                  b(  U=(       d    0 nUR                  U[
        R                  '   U R                  U[        R                  [        R                  U/U[        R                  U-   X4XX5	      $ r   )r   r   
parse_jsonr   JSONr	   CONTENT_TYPEsecurity_tokenSTS_SECURITY_TOKENsend_requestr   signparse_errorr   prefix)	r   http_methodpathr$   headersr%   r   body_parserr&   s	            r   r(   CfcClient._send_request  s    
 ##D1%00K-R-?-D-D))*  ,mG7=7L7LGL334  ););"-"9"9;!G!,i.>.>.E!%A 	Ar   c
           	         [        [        R                  " 5       5      n
[        R                  SXEXxXj5        U=(       d    0 nUR                  b  UR                  U[
        R                  '   / SQnSn[
        R                  U;  a  SnUR                  U[
        R                  '   U HX  nUR                  5       R                  5       nUR                  [
        R                  5      (       d  MG  UR                  U5        MZ     S[        R                   " ["        R$                  5      < S[&        R(                  < S[&        R*                  < 3nUR-                  SS	5      n[        R.                  " U5      nX[
        R0                  '   [        R.                  " U5      nU(       d  S
U[
        R2                  '   Ob[5        U[6        5      (       a  [9        U5      U[
        R2                  '   O0[
        R2                  U;  a  [;        S[
        R2                  -  5      eSn[=        US5      (       a!  [=        US5      (       a  UR?                  5       n[@        RB                  " UR                  URD                  5      u  nnn[G        U5      nUU[
        R                  '   UURD                  RH                  :w  a2  U[
        R                  ==   S[        R.                  " U5      -   -  ss'   [        R.                  " U5      nU" URJ                  XEXxUS9U[
        RL                  '   [@        RN                  " US5      n[9        U5      S
:  a	  US-   U-   nOUn[P        RR                  " U5        S
n/ n Sn USL aE  [@        RT                  " 5       U[
        R                  '   UR                  [
        R                  5        U" URJ                  XEXxUS9U[
        RL                  '   US
:  a  Ub  URW                  U5        [P        RX                  " UUUURZ                  5      n[        R                  SUUXxU5        [P        R\                  " UUUXvUR^                  5      nURa                  5       n[        Rb                  (       a  [5        U[d        5      (       as  / nU Hi  u  nnURg                  S5      Ri                  S5      nURg                  S5      Ri                  S5      nUR                  5       nUR                  UU45        Mk     Un[        R                  SURj                  U4-  5        U	(       a  U$ [P        Rl                  " 5       nURo                  [q        U5      5        U H  nU" UU5      (       d  M    U$    U$ ! [r         a  nUb  URu                  5         UR                  SRw                  S [x        Rz                  " 5       R}                  5        5       5      5        UR~                  R                  UU5      (       a:  UR~                  R                  UU5      n [        R                  " U S-  5         SnAO3[P        R                  " SUSRw                  U5      4-  U5      eSnAff = fGM  )a"  
Send request to BCE services.
:param config
:type config: baidubce.BceClientConfiguration
:param sign_function:
:param response_handler_functions:
:type response_handler_functions: list
:param request:
:type request: baidubce.internal.InternalRequest
:return:
:rtype: baidubce.BceResponse
s#   %s request start: %s %s, %s, %s, %dN)s   hosts   content-lengths   content-typeFTzbce-sdk-python//
r   r   s   No %s is specified.tellseek   :)headers_to_sign   ?z=request args:method=%s, uri=%s, headers=%s,patams=%s, body=%szlatin-1rC   z%request return: status=%d, headers=%sc              3   ,   #    U  H
  nS U-   v   M     g7f)z>>>>Nr   ).0lines     r   	<genexpr>)CfcClient.send_request.<locals>.<genexpr>  s     'fBe$Bes   g     @@zEUnable to execute HTTP request. Retried %d times. All trace backs:
%s)Dinttime_loggerdebugr   r	   r   BCE_DATEendpointHOSTstriplower
startswith
BCE_PREFIXappendr   convert_to_stringbaidubceSDK_VERSIONsysversionplatformreplaceconvert_to_bytes
USER_AGENTCONTENT_LENGTHr   byteslen
ValueErrorhasattrr   r   parse_host_portprotocolr   default_portcredentialsAUTHORIZATIONget_canonical_querystringr   check_headersget_canonical_timer   _get_connectionconnection_timeout_in_mills_send_http_requestsend_buf_size
getheadersPY3listencoderJ   statusBceResponseset_metadata_from_headersdict	Exceptionclosejoin	traceback
format_exc
splitlinesretry_policyshould_retry%get_delay_before_next_retry_in_millissleepBceHttpClientError)!r   r   sign_functionresponse_handler_functionsr   r   r$   r   r%   r&   tr   should_get_new_datekk_lower
user_agentoffsetr   hostportencoded_paramsuriretries_attemptederrorsconnhttp_responseheaders_list
temp_headsvresponsehandler_functionedelay_in_milliss!                                    r   r   CfcClient.send_request  so   $ 		<!$	C-R  ,7=7L7LGL334, $  /"&%+__!!"Aggioo'G!!,"9"9::&&w/ 
 $$X%9%9:CKKW
''b1
,,Z8
+5''(&&t,34GL//0e$$36t9GL//0((73l6Q6QQRR 4  WT6%:%:YY[F$44V__fooV$T{%)!!"6??///L%%&$1H1H1N*NN&&&t,.;7Tc/e**+88G~"+.CC%%g.D=\&$.5:5M5M5OGL112#**<+@+@A6C&&7\k7m223$q(V-?IIf%&66x7;V=_=_a ])3G !0 B B+sG6;O;O!Q  -779 ::*\4"@"@!#J ,1HHY/66w?HHY/66w?GGI"))1a&1	 !-
 $.L;}?S?SUa>bbd ((*6682243EF(B$'x@@	 )C   \#JJLdii'f)BVBVBXBcBcBe'ffg&&33A7HII&,&9&9&_&_,'.OJJ788)<< >BEVEIYYvEVEX>X Z[\ \\e s3   2GU? 4A U? 8U? ;U? ?
Y/	B1Y*?+Y**Y/r   r   )RequestResponseNoneNNN)NNN   bjNFpython2   FNN)NNNNNN)NN)NNNN)NNN)NNNNNF)F)!__name__
__module____qualname____firstlineno____doc__r   r   r0   r3   rY   rg   rk   rp   ru   ry   r|   r   r   r   r   r   r   r   r   r   r   r   staticmethodr   r   r(   r   __static_attributes__r   r   r   r   r   2   s*    F= :KGK-)^ 5FGK!cF LP>B?HMQPd JN;?*X>> <@@D-^> Z^=A;?-^ D> <@9='R <@9='R4 HL.2%N42h1f7r@     -1&+	A. ?DIr   r   )%r6  r   r*   loggingr   r   r   r  rH   r   r   baidubce.authr   baidubce.httpr   r   r   r	   r
   baidubce.services.cfcr   r   baidubce.exceptionr   r   baidubce.utilsr   r   r  urllib.parser   urllib	getLoggerr2  r   r   r   r   r   r   <module>rB     s   
     
    $  ' ) ! , & & - ( - - #  
::"


H
%j-- jr   