o
    #j                     @   s   d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddlm
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ eeZG dd dejZdS )z.
This module provides a client class for CDN.
    N)bce_base_client)bce_v1_signer)bce_http_client)handler)http_content_types)http_headers)http_methods)BceClientError)BceServerError)required)utils)CdnStatsParamc                   @   sV  e Zd ZdZdZdddZdddZddd	Zdd
dZdddZ	dddZ
dddZdddZdddZdddZdddZdddZdddZdddZdd d!Zdd"d#Zdd$d%Zdd&d'Zdd(d)Zdd*d+Zdd,d-Zdd.d/Zdd0d1Zdd2d3Zdd4d5Zdd6d7Zdd8d9Zdd:d;Z dd<d=Z!dd>d?Z"dd@dAZ#ddBdCZ$ddDdEZ%ddFdGZ&ddHdIZ'ddJdKZ(ddLdMZ)ddNdOZ*ddPdQZ+ddRdSZ,ddTdUZ-ddVdWZ.ddXdYZ/ddZd[Z0dd\d]Z1		dd^d_Z2dd`daZ3ddbdcZ4ddddeZ5ddfdgZ6ddhdiZ7ddjdkZ8ddldmZ9ddndoZ:ddpdqZ;ddrdsZ<ddtduZ=ddvdwZ>e?e@eAdxddydzZBdd{d|ZCe?e@d}		dddZDe?e@d}dddZEe?e@eFddddZGe?e@eHddddZIe?e@eFddddZJe?eKddddZL			dddZM			dddZN			dddZO			dddZP			dddZQ			dddZR			dddZS			dddZT			dddZUe?eAddddZV			dddZWe?eAddddZX			dddZYdddZZdddZ[dddZ\dddZ]e?e@d}dddZ^e?e@d}dddZ_e?e@d}dddZ`eadd Zb			dddZcdS )	CdnClientz
    CdnClient
    s   /v2Nc                 C   s   t j| | d S N)r   BceBaseClient__init__selfconfig r   a/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/baidubce/services/cdn/cdn_client.pyr   ,   s   zCdnClient.__init__c                 C      | j tjd|dS )z
        get domain list

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

        :return:
        :rtype: baidubce.bce_response.BceResponse
        z/domainr   _send_requestr   GETr   r   r   r   list_domains/   s
   
zCdnClient.list_domainsc                 C   s0   i }||d< |dur||d< | j tjd||dS )aj  
        get user domain list

        :param status: Specify the domain whose return 'status' is status
        :type status: string
        :param rule: domain Fuzzy Matching
        :type rule: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        statusNrulez/user/domainsparamsr   r   )r   r   r   r   r    r   r   r   list_user_domains>   s   zCdnClient.list_user_domainsc                 C   s   | j tjd| d |dS )a  
        query if a domain can be create
        
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        /domain/z/validr   r   r   domainr   r   r   r   valid_domainW   s
   
zCdnClient.valid_domainc                 C       | j tjd| d ddi|dS )a
  
        get cache full url of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   /configcacheFullUrl r   r   r#   r   r   r   get_domain_cache_full_urlh   
   z#CdnClient.get_domain_cache_full_urlc                 C   ,   | j tjd| d dditd|i|dS )ar  
        update cacheShare of the domain
        :param domain: the domain name
        :type domain: string
        :param cache_share: detailed configuration of cacheShare
        :type cache_share: dictionary
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   
cacheSharer)   r    bodyr   r   r   PUTjsondumps)r   r$   Zcache_sharer   r   r   r   set_domain_cache_sharey      
z CdnClient.set_domain_cache_sharec                 C   r&   )a  
        get cacheShare configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r-   r)   r   r   r#   r   r   r   get_domain_cache_share   r+   z CdnClient.get_domain_cache_sharec                 C   r,   )az  
        update trafficLimit of the domain
        :param domain: the domain name
        :type domain: string
        :param traffic_limit: detailed configuration of trafficLimit
        :type traffic_limit: dictionary
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   trafficLimitr)   r.   r0   )r   r$   Ztraffic_limitr   r   r   r   set_domain_traffic_limit   r5   z"CdnClient.set_domain_traffic_limitc                 C   r&   )a  
        get trafficLimit configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r7   r)   r   r   r#   r   r   r   get_domain_traffic_limit   r+   z"CdnClient.get_domain_traffic_limitc                 C   r,   )a^  
        update uaAcl of the domain
        :param domain: the domain name
        :type domain: string
        :param ua_acl: detailed configuration of uaAcl
        :type ua_acl: dictionary
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   uaAclr)   r.   r0   )r   r$   Zua_aclr   r   r   r   set_domain_ua_acl   r5   zCdnClient.set_domain_ua_aclc                 C   r&   )a  
        get uaAcl configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r:   r)   r   r   r#   r   r   r   get_domain_ua_acl   r+   zCdnClient.get_domain_ua_aclc                 C   r,   )a  
        update originProtocol of the domain
        :param domain: the domain name
        :type domain: string
        :param origin_protocol: detailed configuration of originProtocol
        :type origin_protocol: dictionary
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   originProtocolr)   r.   r0   )r   r$   origin_protocolr   r   r   r   set_domain_origin_protocol   r5   z$CdnClient.set_domain_origin_protocolc                 C   r&   )a  
        get originProtocol configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r=   r)   r   r   r#   r   r   r   get_domain_origin_protocol   r+   z$CdnClient.get_domain_origin_protocolc                 C   r,   )av  
        update retryOrigin of the domain
        :param domain: the domain name
        :type domain: string
        :param retry_origin: detailed configuration of retryOrigin
        :type retry_origin: dictionary
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   retryOriginr)   r.   r0   )r   r$   Zretry_originr   r   r   r   set_domain_retry_origin  r5   z!CdnClient.set_domain_retry_originc                 C   r&   )a  
        get retryOrigin configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rA   r)   r   r   r#   r   r   r   get_domain_retry_origin&  r+   z!CdnClient.get_domain_retry_originc                 C   r,   )a  
        update ipv6Dispatch of the domain
        :param domain: the domain name
        :type domain: string
        :param ipv6_dispatch: detailed configuration of IPv6 access and IPv6 back to source
        :type ipv6_dispatch: IPv6Config
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   ipv6Dispatchr)   r.   r0   )r   r$   Zipv6_dispatchr   r   r   r   set_domain_ipv6_dispatch7  r5   z"CdnClient.set_domain_ipv6_dispatchc                 C   r&   )a  
        get ipv6Dispatch configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rD   r)   r   r   r#   r   r   r   get_domain_ipv6_dispatchL  r+   z"CdnClient.get_domain_ipv6_dispatchc                 C   r,   )ak  
        update QUIC of the domain
        :param domain: the domain name
        :type domain: string
        :param quic: detailed configuration of Quick UDP Internet Connection
        :type quic: bool
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   quicr)   r.   r0   )r   r$   rG   r   r   r   r   set_domain_quic]  r5   zCdnClient.set_domain_quicc                 C   r&   )a  
        get quic configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rG   r)   r   r   r#   r   r   r   get_domain_quicr  r+   zCdnClient.get_domain_quicc                 C   r,   )ap  
        update offlineMode of the domain
        :param domain: the domain name
        :type domain: string
        :param offline_mode: detailed configuration of offlineMode
        :type offline_mode: bool
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   offlineModer)   r.   r0   )r   r$   Zoffline_moder   r   r   r   set_domain_offline_mode  r5   z!CdnClient.set_domain_offline_modec                 C   r&   )a  
        get offlineMode configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rJ   r)   r   r   r#   r   r   r   get_domain_offline_mode  r+   z!CdnClient.get_domain_offline_modec                 C   r,   )a~  
        update OCSP configuration of the domain
        :param domain: the domain name
        :type domain: string
        :param ocsp: detailed configuration of Online Certificate Status Protocol
        :type ocsp: bool
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   ocspr)   r.   r0   )r   r$   rM   r   r   r   r   set_domain_ocsp  r5   zCdnClient.set_domain_ocspc                 C   r&   )a  
        get ocsp configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rM   r)   r   r   r#   r   r   r   get_domain_ocsp  r+   zCdnClient.get_domain_ocspc                 C   r,   )a  
        update error_page of the domain
        :param domain: the domain name
        :type domain: string
        :param error_page: Detailed configuration of custom error jump pages
        :type error_page: list<ErrorPage>
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   	errorPager)   r.   r0   )r   r$   Z
error_pager   r   r   r   set_domain_error_page  r5   zCdnClient.set_domain_error_pagec                 C   r&   )a  
        get error page configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rP   r)   r   r   r#   r   r   r   get_domain_error_page  r+   zCdnClient.get_domain_error_pagec                 C   r&   )a  
        get referer acl configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   
refererACLr)   r   r   r#   r   r   r   get_domain_referer_acl  r+   z CdnClient.get_domain_referer_aclc                 C   r&   )a  
        get ip acl configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   ipACLr)   r   r   r#   r   r   r   get_domain_ip_acl  r+   zCdnClient.get_domain_ip_aclc                 C   r,   )aa  
        update cors of the domain
        :param domain: the domain name
        :type domain: string
        :param cors: Accelerating Cross-domain Settings for Domain Names
        :type cors
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   corsr)   r.   r0   )r   r$   rW   r   r   r   r   set_domain_cors  r5   zCdnClient.set_domain_corsc                 C   r&   )a  
        get cors configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rW   r)   r   r   r#   r   r   r   get_domain_cors*  r+   zCdnClient.get_domain_corsc                 C   r,   )aa  
        update access limit of the domain
        :param domain: the domain name
        :type domain: string
        :param access_limit: Setting IP Access Limitation
        :type AccessLimit
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   accessLimitr)   r.   r0   )r   r$   Zaccess_limitr   r   r   r   set_domain_access_limit:  r5   z!CdnClient.set_domain_access_limitc                 C   r&   )a  
        get access limit configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rZ   r)   r   r   r#   r   r   r   get_domain_access_limitN  r+   z!CdnClient.get_domain_access_limitc                 C   r,   )a_  
        update Getting Real User IP Settings
        :param domain: the domain name
        :type domain: string
        :param client_ip: Getting Real User IP Settings
        :type ClientIp
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   clientIpr)   r.   r0   )r   r$   Z	client_ipr   r   r   r   set_domain_client_ip^  r5   zCdnClient.set_domain_client_ipc                 C   r&   )a  
        get client ip configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r]   r)   r   r   r#   r   r   r   get_domain_client_ipr  r+   zCdnClient.get_domain_client_ipc                 C   r,   )aW  
        update range backsource Settings
        :param domain: the domain name
        :type domain: string
        :param range_switch: rangre backsource settings
        :type bool
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rangeSwitchr)   r.   r0   )r   r$   Zrange_switchr   r   r   r   set_domain_range_switch  r5   z!CdnClient.set_domain_range_switchc                 C   r&   )  
        get range switch configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r`   r)   r   r   r#   r   r   r   get_domain_range_switch  r+   z!CdnClient.get_domain_range_switchc                 C   r,   )aY  
        update mobile access Settings
        :param domain: the domain name
        :type domain: string
        :param mobile_access: mobile access settings
        :type MobileAccess
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   mobileAccessr)   r.   r0   )r   r$   Zmobile_accessr   r   r   r   set_domain_mobile_access  r5   z"CdnClient.set_domain_mobile_accessc                 C   r&   )a  
        get mobile access configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rd   r)   r   r   r#   r   r   r   get_domain_mobile_access  r+   z"CdnClient.get_domain_mobile_accessc                 C   r,   )aQ  
        update http header Settings
        :param domain: the domain name
        :type domain: string
        :param http_header: http header settings
        :type HttpHeader
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   
httpHeaderr)   r.   r0   )r   r$   Zhttp_headerr   r   r   r   set_domain_http_header  r5   z CdnClient.set_domain_http_headerc                 C   r&   )a  
        get http header configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rg   r)   r   r   r#   r   r   r   get_domain_http_header  r+   z CdnClient.get_domain_http_headerc                 C   r,   )aE  
        update file trim Settings
        :param domain: the domain name
        :type domain: string
        :param file_trim: file trim settings
        :type bool
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   fileTrimr)   r.   r0   )r   r$   Z	file_trimr   r   r   r   set_domain_file_trim  r5   zCdnClient.set_domain_file_trimc                 C   r&   )a  
        get file trim configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rj   r)   r   r   r#   r   r   r   get_domain_file_trim  r+   zCdnClient.get_domain_file_trimc                 C   s,   | j tjd| d dditd|i|dS )aQ  
        update media drag Settings
        :param domain: the domain name
        :type domain: string
        :param media_drag: media drag settings
        :type MediaDragConf
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   	mediaDragr)   ZmediaDragConfr.   r0   )r   r$   Z
media_dragr   r   r   r   set_domain_media_drag  r5   zCdnClient.set_domain_media_dragc                 C   r&   )rb   r"   r'   rm   r)   r   r   r#   r   r   r   get_domain_media_drag&  r+   zCdnClient.get_domain_media_dragc                 C   r,   )aH  
        update compress Settings
        :param domain: the domain name
        :type domain: string
        :param compress: media drag settings
        :type compress
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   compressr)   r.   r0   )r   r$   rp   r   r   r   r   set_domain_compress6  r5   zCdnClient.set_domain_compressc                 C   r&   )a  
        get compress configuration of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   rp   r)   r   r   r#   r   r   r   get_domain_compressJ  r+   zCdnClient.get_domain_compressc                 C   st   i }|dur
||d< |dur||d< |dur||d< |dur"||d< |dur*||d< |du r0i }| j tjd||dS )	a  
        Query refresh and preload records
        :param Type: None
        :type string
        :param start_time: None
        :type Timestamp
        :param end_time: None
        :type Timestamp
        :param url: None
        :type string
        :param marker: None
        :type string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        Ntype	startTimeendTimeurlmarkerz/cache/recordsr   r   )r   Type
start_timeZend_timerv   rw   r   r    r   r   r   get_domain_recordsZ  s$   zCdnClient.get_domain_recordsc                 C   s   | j tjdtd|i|dS )z
        set das enable
        :param action: dsa enable
        :type string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        z/dsaactionr/   r   r0   )r   r{   r   r   r   r   set_dsa  s   zCdnClient.set_dsac                 C   r,   )a@  
        update domain dsa Settings
        :param domain: the domain name
        :type domain: string
        :param dsa: domain dsa settings
        :type DSA
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   dsar)   r.   r0   )r   r$   r~   r   r   r   r   set_domain_dsa  r5   zCdnClient.set_domain_dsac                 C   r   )z
        get dsa domain list
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        z/dsa/domainr   r   r   r   r   r   get_dsa_domains  s
   	zCdnClient.get_dsa_domainsc                 C   s   | j tjdt||dS )z
        get log list
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        z	/log/listr|   r   r   POSTr2   r3   )r   logr   r   r   r   get_log_list  s   	zCdnClient.get_log_listc                 C   s8   d|i}|dur| | | jtjd| t||dS )a  
        create domain
        :param domain: the domain name
        :type domain: string
        :param origin: the origin address list
        :type origin: list<OriginPeer>
        :param other: the other config
        :type other: list<CONFIG>
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        originNr"   r|   updater   r   r1   r2   r3   r   r$   r   otherr   r/   r   r   r   create_domain  s   
zCdnClient.create_domainc                 C   s   | j tjd| |dS )z
        delete a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r   )r   r   DELETEr#   r   r   r   delete_domain  s
   zCdnClient.delete_domainc                 C      | j tjd| ddi|dS )z
        enable a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   enabler)   r   r   r   r   r#   r   r   r   enable_domain     zCdnClient.enable_domainc                 C   r   )z
        disable a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   disabler)   r   r   r#   r   r   r   disable_domain  r   zCdnClient.disable_domainc                 C   s6   |d dkrd|dd  }| j tjd| d |dS )	a  
        get configuration of the domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r   *z%2A   Nr"   r'   r   r   r#   r   r   r   get_domain_config  s   
zCdnClient.get_domain_configc                 C   r,   )al  
        update multiConfigs of the domain
        :param domain: the domain name
        :type domain: string
        :param multi_configs: the domain config list
        :type multi_configs: list<config>
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   ZmultiConfigsr)   r.   r0   )r   r$   Zmulti_configsr   r   r   r   set_domain_multi_configs(  r5   z"CdnClient.set_domain_multi_configsc                 C   sB   d|i}|dur| | | jtjd| d ddit||dS )a  
        update origin address of the domain
        :param domain: the domain name
        :type domain: string
        :param origin: the origin address list
        :type origin: list<OriginPeer>
        :param other: origin extension configuration
        :type other: dictionary
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r   Nr"   r'   r)   r.   r   r   r   r   r   set_domain_origin<  s   

zCdnClient.set_domain_originc                 C   r&   )a  
        get cache rules of a domain
        :param domain: the domain name
        :type domain: string
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   cacheTTLr)   r   r   r#   r   r   r   get_domain_cache_ttlV  r+   zCdnClient.get_domain_cache_ttl)r$   rulesc                 C   r,   )aC  
        set cache rules of a domain
        :param domain: the domain name
        :type domain: string
        :param rules: cache rules
        :type rules: list
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r   r)   r.   r0   )r   r$   r   r   r   r   r   set_domain_cache_ttlf  s   
zCdnClient.set_domain_cache_ttlc                 C   r,   )a?  
        set if use the full url as cache key
        :param domain: the domain name
        :type domain: string
        :param flag: 
        :type flag: bool
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r(   r)   r.   r0   )r   r$   flagr   r   r   r   set_domain_cache_full_url{  r5   z#CdnClient.set_domain_cache_full_url)r$   Tc                 C   sX   i }||d< |dur||d< |dur||d< | j tjd| d dditd|i|d	S )
a  
        set request referer access control
        :param domain: the domain name
        :type domain: string
        :param blackList: referer blackList
        :type blackList: list
        :param whitelist: referer whitelist
        :type whitelist: list
        :param allowempty: allow empty referer?
        :type allowempty: bool
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        
allowEmptyN	blackList	whiteListr"   r'   rS   r)   r.   r0   )r   r$   r   r   r   r   aclr   r   r   set_domain_referer_acl  s   z CdnClient.set_domain_referer_aclc                 C   sP   i }|dur
||d< |dur||d< | j tjd| d dditd|i|dS )	a  
        set request ip access control
        :param domain: the domain name
        :type domain: string
        :param blackList: ip blackList
        :type blackList: list
        :param whitelist: ip whitelist
        :type whitelist: list
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        Nr   r   r"   r'   rU   r)   r.   r0   )r   r$   r   r   r   r   r   r   r   set_domain_ip_acl  s   zCdnClient.set_domain_ip_acl)r$   httpsc                 C   r,   )aF  
        set request ip access control
        :param domain: the domain name
        :type domain: string
        :param https: https config
        :type https: dict
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r   r)   r.   r0   )r   r$   r   r   r   r   r   set_domain_https  s   zCdnClient.set_domain_https)r$   	limitRatec                 C   r,   )aK  
        set limit rate
        :param domain: the domain name
        :type domain: string
        :param limitRate: limit rate value (Byte/s)
        :type limitRate: int
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r   r)   r.   r0   )r   r$   r   r   r   r   r   set_domain_limit_rate     zCdnClient.set_domain_limit_rate)r$   Zrequest_authc                 C   r,   )aG  
        set request auth
        :param domain: the domain
        :type domain: string
        :param requestAuth: request auth config
        :type requestAuth: dict
        :param config: None
        :type config: baidubce.BceClientConfiguration
        :return:
        :rtype: baidubce.bce_response.BceResponse

        r"   r'   requestAuthr)   r.   r0   )r   r$   r   r   r   r   r   set_domain_request_auth  r   z!CdnClient.set_domain_request_auth)paramc                 C   s   | j tjdt|j|dS )a>  
        query stats of the domain or uid or tagId, eg : flow pv
        :param param: the stats query param
        :type param: cdn_stats_param.CdnStatsParam
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        z/stat/queryr|   )r   r   r   r2   r3   __dict__)r   r   r   r   r   r   get_domain_stats  s   
zCdnClient.get_domain_stats,  c                 C   P   i }||d< |dur||d< |dur||d< ||d< ||d< | j tjd||dS )	aK  
        query pv and qps of the domain
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param period: time interval of query result
        :type period: int
        :param withRegion: if need client region distribution
        :type withRegion: any
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r$   Nrt   ru   period
withRegionz/stat/pvr   r   r   r$   rt   ru   r   r   r   r    r   r   r   get_domain_pv_stat     zCdnClient.get_domain_pv_statc                 C   r   )	aJ  
        query bandwidth of the domain
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param period: time interval of query result
        :type period: int
        :param withRegion: if need client region distribution
        :type withRegion: any
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r$   Nrt   ru   r   r   z
/stat/flowr   r   r   r   r   r   get_domain_flow_statA  s   zCdnClient.get_domain_flow_statc                 C   H   i }||d< |dur||d< |dur||d< ||d< | j tjd||dS )a  
        query origin bandwidth of the domain
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param period: time interval of query result
        :type period: int
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r$   Nrt   ru   r   z/stat/srcflowr   r   r   r$   rt   ru   r   r   r    r   r   r   get_domain_src_flow_statf     z"CdnClient.get_domain_src_flow_statc                 C   r   )a  
        query hit rate of the domain
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param period: time interval of query result
        :type period: int
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r$   Nrt   ru   r   z/stat/hitrater   r   r   r   r   r   get_domain_hitrate_stat  s   z!CdnClient.get_domain_hitrate_statc                 C   r   )	al  
        query http response code of a domain or all domains of the user
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param period: time interval of query result
        :type period: int
        :param withRegion: if need client region distribution
        :type withRegion: any
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r$   Nrt   ru   r   r   z/stat/httpcoder   r   r   r   r   r   get_domain_httpcode_stat  r   z"CdnClient.get_domain_httpcode_statc                 C   r   )a	  
        query top n url of the domain or all domains of the user
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param period: time interval of query result
        :type period: int
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r$   Nrt   ru   r   z/stat/topn/urlr   r   r   r   r   r   get_domain_topn_url_stat  r   z"CdnClient.get_domain_topn_url_statc                 C   r   )a  
        query top n referer of the domain or all domains of the user
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param period: time interval of query result
        :type period: int
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r$   Nrt   ru   r   z/stat/topn/refererr   r   r   r   r   r   get_domain_topn_referer_stat  r   z&CdnClient.get_domain_topn_referer_stat  c                 C   r   )a  
        query the total number of client of a domain or all domains of the user
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param period: time interval of query result
        :type period: int
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r$   Nrt   ru   r   z/stat/uvr   r   r   r   r   r   get_domain_uv_stat  r   zCdnClient.get_domain_uv_statc                 C   r   )a  
        query average of the domain or all domains of the user
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param period: time interval of query result
        :type period: int
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r$   Nrt   ru   r   z/stat/avgspeedr   r   r   r   r   r   get_domain_avg_speed_stat3  r   z#CdnClient.get_domain_avg_speed_stat)tasksc                 C   &   i }||d< | j tjd|t|dS )a$  
        purge the cache of specified url or directory
        :param tasks: url or directory list to purge
        :type tasks: list
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r   /cache/purger   r/   r   r   r   r   r/   r   r   r   purgeU  s   
zCdnClient.purgec                 C   P   i }||d< ||d< |dur||d< |dur||d< ||d< | j tjd||dS )	a3  
        query the status of purge tasks
        :param id: purge task id to query
        :type id: string
        :param url: purge url to query
        :type url: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param marker: 'nextMarker' get from last query
        :type marker: int
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        idrv   Nrt   ru   rw   r   r   r   r   r   rv   rt   ru   rw   r   r    r   r   r   list_purge_tasksg     zCdnClient.list_purge_tasksc                 C   r   )a,  
        prefetch the source of specified url from origin
        :param tasks: url or directory list need prefetch
        :type tasks: list
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r   /cache/prefetchr   r   r   r   r   r   prefetch  s   
zCdnClient.prefetchc                 C   r   )	a<  
        query the status of prefetch tasks
        :param id: prefetch task id to query
        :type id: string
        :param url: prefetch url to query
        :type url: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param marker: 'nextMarker' get from last query
        :type marker: int
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r   rv   Nrt   ru   rw   r   r   r   r   r   r   r   list_prefetch_tasks  r   zCdnClient.list_prefetch_tasksc                 C   r   )z
        query purge quota of the user
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        z/cache/quotar   r   r   r   r   r   
list_quota  s   	zCdnClient.list_quotac                 C   s@   i }|dur
||d< |dur||d< | j tjd| d ||dS )a  
        get log of the domain in specified period of time
        :param domain: the domain name
        :type domain: string
        :param startTime: query start time
        :type startTime: Timestamp
        :param endTime: query end time
        :type endTime: Timestamp
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        Nrt   ru   z/log/z/logr   r   )r   r$   rt   ru   r   r    r   r   r   get_domain_log  s   
zCdnClient.get_domain_logc                 C   s4   i }||d< ||d< |du ri }| j tjd||dS )z
        check specified ip whether belongs to Baidu CDN
        :param action: 'describeIp'
        :type action: string
        :param ip: specified ip
        :type ip: string
        r{   ipNz/utilsr   r   )r   r{   r   r   r    r   r   r   ip_query  s   zCdnClient.ip_queryc                 C   s   | j tjdi |dS )z
        Baidu back source IP address segment query

        :return:
        :rtype: baidubce.bce_response.BceResponse
        z/nodes/listr   r   r   r   r   r   
list_nodes  s
   zCdnClient.list_nodesFc                 C   sR   t  }|rdnd|d< |rdnd|d< | jtjd| d dditd|i|d	S )
a  
        set seo
        :param domain: the domain name
        :type domain: string
        :param push_record: push record to baidu or not
        :type param: boolean
        :param directory_origin: directory access origin or not
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        ONZOFFZ
pushRecordZdiretlyOriginr"   r'   	seoSwitchr)   r.   )dictr   r   r1   r2   r3   )r   r$   Zpush_recordZdirectory_originr   r/   r   r   r   set_seo  s   
zCdnClient.set_seoc                 C   r&   )z
        get seo configuration.
        :param domain: the domain name
        :type domain: string

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   r   r)   r   r   r#   r   r   r   get_seo%  s   

zCdnClient.get_seoc                 C   r,   )z
        set follow protocol.
        :param domain: the domain name
        :type domain: string
        :param follow: follow protocol or not
        :type follow: boolean

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r"   r'   ZfollowProtocolr)   r.   r0   )r   r$   followr   r   r   r   set_follow_protocol5  s   
zCdnClient.set_follow_protocolc                 C   s(   |d u r| j S t| j }|| |S r   )r   copyZmerge_non_none_values)r   r   Z
new_configr   r   r   _merge_configH  s
   
zCdnClient._merge_configc              
   C   sD   |  | |}|d u rtj}t|tjtj|g|t	t
j||||S r   )r   r   Z
parse_jsonr   send_requestr   signZparse_errorr   Z
append_urir   prefix)r   Zhttp_methodpathr/   headersr    r   Zbody_parserr   r   r   r   Q  s   zCdnClient._send_requestr   )NN)NNNNNN)NNTN)NNN)NNNr   NN)NNNr   N)NNNr   N)FFN)NNNNN)d__name__
__module____qualname____doc__r   r   r   r!   r%   r*   r4   r6   r8   r9   r;   r<   r?   r@   rB   rC   rE   rF   rH   rI   rK   rL   rN   rO   rQ   rR   rT   rV   rX   rY   r[   r\   r^   r_   ra   rc   re   rf   rh   ri   rk   rl   rn   ro   rq   rr   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   strlistr   r   r   r   r   r   intr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   staticmethodr   r   r   r   r   r   r   &   s    














































.












!



$
%
"
!
$
"
"
"
"
%

%




r   )r   r   r2   loggingZbaidubcer   Zbaidubce.authr   Zbaidubce.httpr   r   r   r   r   Zbaidubce.exceptionr	   r
   Zbaidubce.utilsr   r   Z%baidubce.services.cdn.cdn_stats_paramr   	getLoggerr   _loggerr   r   r   r   r   r   <module>   s&   
