o
    eP                    @   s   d Z ddlmZ ddlZddl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 eeZdZdZdZedZe ZG dd de
j Z!dd Z"dd Z#e"Z$dS )z.
This module provides a client class for BCC.
    )unicode_literalsN)bce_base_client)bce_v1_signer)bce_http_client)handler)http_methods)	bcc_model)aes128_encrypt_16char_key)required)compats   syncs   asyncZAES256ZPostpaidc                   @   sf  e Zd ZdZdZdZddZdZddZ		d[dd	Zee	e	e
efd
													d\ddZee	e	e
efe
efd				d]ddZee	e	e
efe
efd				d]ddZee	e	e
efd
													d^ddZ				d_ddZee
efdd`ddZee
efddZddZee
efddaddZee
efdd`d d!Zeeddbd"d#Zeeed$dZd%d&Zee
efe
efd'dZd(d)Zee
efe
efd*dZd+d,Zee
efe
efd-dZd.d/Zee
efe
efd0		dbd1d2Zee
efddZd3d4Zee
efe	e	d5		dcd6d7Zee
efe
efd8dZd9d:Zee
efe
efd8dZd;d<Zee
efed=dZd>d?Z ee
efed=dZd@dAZ!ee
efddZdBdCZ"ee
efd				dddDdEZ#dZdFdGZ$ee	dH							dedJdKZ%ee
efdL							dfdMdNZ&			d[dOdPZ'ee
efdQdZdRdSZ(ee
efe
efdTdZdUdVZ)ee
efe
efdTdZdWdXZ*ee
efdQdZdYdZZ+ee
efe	d[	dgd\d]Z,ee
efe
efd^dZd_d`Z-ee
efdQ			dbdadbZ.ee
efe
efe
efdc	dZdddeZ/ee
efdQ		dgdfdgZ0ee
efe
efdh				dhdidjZ1ee
efe
efdk			dbdldmZ2		didodpZ3ee
efdqdZdrdsZ4ee
efdqdZdtduZ5ee
efe
efedv	dZdwdxZ6ee
efdq	dZdydzZ7ee
efdq			dbd{d|Z8ee
efdq			dbd}d~Z9ee
efdq	dZddZ:eed		dgddZ;ee
efe
efd				ddddZ<ddddZ=ee
efdLdZddZ>ee
efdLdZddZ?ee
efed					dcddZ@		dcddZAee
efddZddZBee
efeCjDd		dgddZEee
efeCjDddgddZFdZddZGee
efeee
efd						d[ddZHee
efed			dbddZIee
efed			dbddZJee
efd		dgddZKdcddZLee
efddgddZMee
efd			dbddZNee
efe
efd				ddddZOddddZPee
efddgddZQee
efed			dbddZRee
efed			dbddZSee
efd		dgddZTee
efe
efd			dbddZUee
efe
efd			dbddÄZVee	dč				djddɄZW		dcdd˄ZXee
efd̍dZdd΄ZYee
efe	dύdgddфZZee
efd̍		dkddӄZ[ee
efd̍		dkddՄZ\ee
efd̍dgddׄZ]		dlddلZ^eee
efdڍ											dmdd܄Z_ee
efddbddބZ`ee
efd			d[ddZaee
efddgddZbee
efddgddZcee
efed		ddddZdeeddgddZeeee	e	d					dnddZfdgddZgee
efe	ddgddZhee
efdQddddZieee	eddgddZjeedQdgddZkeeddgddZleedQddddZmeedQdddd ZneedQ		d[ddZoeeddbddZpeeddbddZq		dodd	Zr		dld
dZs		d[ddZt		dcddZu		dcddZveeddgddZwdbddZxdgddZy		dbddZzdbddZ{		doddZ|dgddZ}		dpd d!Z~dgd"d#Zdgd$d%Zddd&d'Zdgd(d)Z			d[d*d+Zdgd,d-Z		ddd.d/Zdgd0d1Z		dcd2d3Z		dcd4d5Zdgd6d7Zdgd8d9Zdgd:d;Zdgd<d=Zdgd>d?Zdqd@dAZdqdBdCZdgdDdEZdgdFdGZdgdHdIZdgdJdKZdcdLdMZdgdNdOZdgdPdQZdddRdSZdgdTdUZ		dbdVdWZdgdXdYZdS (r  	BccClientz
    Bcc base sdk client
    s   /v2Nc                 C   s   t j| | d S N)r   BceBaseClient__init__)selfconfig r   PD:\Projects\ConvertPro\env\Lib\site-packages\baidubce/services/bcc/bcc_client.pyr   6   s   zBccClient.__init__c                 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_config9   s
   
zBccClient._merge_configc	           	   
   C   sJ   |  |}|d u rtj}|d u rtj}t|tjtj	|g||| |||S r   )
r   r   Z
parse_jsonr   prefixr   send_requestr   signZparse_error)	r   Zhttp_methodpathbodyheadersparamsr   Zbody_parserr   r   r   r   _send_requestA   s   
zBccClient._send_request)	cpu_countmemory_capacity_in_gbimage_idr   F   c4           ;      C   s  d}4i }5|2du rt  |5d< n|2|5d< |du rt}||||jd}6|!dur(|!|6d< |"dur0|"|6d< |#dur8|#|6d< |$dur@|$|6d< |%durH|%|6d	< |&durP|&|6d
< |'durX|'|6d< |-durgdd |-D }7|7|6d< |.duro|.|6d< |/durw|/|6d< |0dur|0|6d< |dur||6d< |dkr||6d< |dur||6d< |dur||6d< |dkr||6d< |dkr||6d< |dur||6d< |dur| jjj}8t||8}9|9|6d< |dur||6d< |dur||6d< |dur||6d< |(dur|(|6d< |)dur|)|6d< |*dur|*|6d < |dur||6d!< |d"kr	|nd"|6d#< | dur!| |6d$< |d"kr|nd"|6d#< |+dur5|+|6d%< |d"kr1|nd"|6d#< |,durI|,|6d&< |d"krE|nd"|6d#< |dkrR||6d'< |du r\d(|6d)< n||6d)< |	duri|	|6d*< |
durr|
|6d+< |dur{||6d,< |dur||6d-< |dur||6d.< |dur||6d/< |dur||6d0< |dur||6d1< |dur||6d2< |durd3d |D }:|:|6d4< |dur||6d5< |1dur|1|6d6< ||6d7< | jtj	|4t
|6|5|3d8S )9a'"  
        Create a bcc Instance with the specified options.
        You must fill the field of clientToken,which is especially for keeping idempotent.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param instance_type:
            The specified Specification to create the instance,
            See more detail on
            https://cloud.baidu.com/doc/BCC/API.html#InstanceType
        :type instance_type: string

        :param cpu_count:
            The parameter to specified the cpu core to create the instance.
        :type cpu_count: int

        :param memory_capacity_in_gb:
            The parameter to specified the capacity of memory in GB to create the instance.
        :type memory_capacity_in_gb: int

        :param image_id:
            The id of image, list all available image in BccClient.list_images.
        :type image_id: string

        :param billing:
            Billing information.
        :type billing: bcc_model.Billing

        :param create_cds_list:
            The optional list of volume detail info to create.
        :type create_cds_list: list<bcc_model.CreateCdsModel>

        :param network_capacity_in_mbps:
            The optional parameter to specify the bandwidth in Mbps for the new instance.
            It must among 0 and 200, default value is 0.
            If it's specified to 0, it will get the internal ip address only.
        :type network_capacity_in_mbps: int

        :param purchase_count:
            The number of instance to buy, the default value is 1.
        :type purchase_count: int

        :param name:
            The optional parameter to desc the instance that will be created.
        :type name: string

        :param admin_pass:
            The optional parameter to specify the password for the instance.
            If specify the adminPass,the adminPass must be a 8-16 characters String
            which must contains letters, numbers and symbols.
            The symbols only contains "!@#$%^*()".
            The adminPass will be encrypted in AES-128 algorithm
            with the substring of the former 16 characters of user SecretKey.
            If not specify the adminPass, it will be specified by an random string.
            See more detail on
            https://bce.baidu.com/doc/BCC/API.html#.7A.E6.31.D8.94.C1.A1.C2.1A.8D.92.ED.7F.60.7D.AF
        :type admin_pass: string

        :param zone_name:
            The optional parameter to specify the available zone for the instance.
            See more detail through list_zones method
        :type zone_name: string

        :param subnet_id:
            The optional parameter to specify the id of subnet from vpc, optional param
             default value is default subnet from default vpc
        :type subnet_id: string

        :param security_group_id:
            The optional parameter to specify the securityGroupId of the instance
            vpcId of the securityGroupId must be the same as the vpcId of subnetId
            See more detail through listSecurityGroups method
        :type security_group_id: string

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :param fpgaCard:
            specify the fpgaCard info of creating FPGA instance,
            see all of supported fpga card type at baidubce.services.bcc.fpga_card_type
        :type gpuCard: string

        :param gpuCard:
            specify the gpuCard info of creating GPU instance,
            see all of supported gpu card type at baidubce.services.bcc.gpu_card_type
        :type gpuCard: string

        :param cardCount:
            The parameter to specify the card count for creating GPU/FPGA instance
        :type cardCount: int

        :param root_disk_size_in_gb:
            The parameter to specify the root disk size in GB.
            The root disk excludes the system disk, available is 40-500GB.
        :type root_disk_size_in_gb: int

        :param root_disk_storage_type:
            The parameter to specify the root disk storage type.
            Default use of HP1 cloud disk.
        :type root_disk_storage_type: string

        :param ephemeral_disks:
            The optional list of ephemeral volume detail info to create.
        :type ephemeral_disks: list<bcc_model.EphemeralDisk>

        :param dedicate_host_id:
            The parameter to specify the dedicate host id.
        :type dedicate_host_id: string

        :param auto_renew_time_unit:
            The parameter to specify the unit of the auto renew time.
            The auto renew time unit can be "month" or "year".
            The default value is "month".
        :type auto_renew_time_unit: string

        :param auto_renew_time:
            The parameter to specify the auto renew time, the default value is 0.
        :type auto_renew_time: int

        :param tags:
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :param deploy_id:
            The parameter to specify the id of the deploymentSet.
        :type deploy_id: string

        :param bid_model:
            The parameter to specify the bidding model.
            The bidding model can be "market" or "custom".
        :type bid_model: string

        :param bid_price:
            The parameter to specify the bidding price.
            When the bid_model is "custom", it works.
        :type bid_price: string

        :param key_pair_id:
            The parameter to specify id of the keypair.
        :type key_pair_id: string

        :param asp_id:
            The parameter to specify id of the asp.
        :type asp_id: string

        :param request_token:
            The parameter to specify the request token which will make the request idempotent.
        :type request_token: string

        :param internet_charge_type:
            The parameter to specify the internet charge type.
            See more detail on
            https://cloud.baidu.com/doc/BCC/API.html#InternetChargeType
        :type internet_charge_type: string

        :param internal_ips:
            The parameter to specify the internal ips.
        :type internal_ips: list<string>

        :param cds_auto_renew
            The parameter to specify whether the cds is auto renew or not.
            The default value is false.
        :type cds_auto_renew: boolean

        :param spec:
            spec
        :type spec: string

        :param eip_name:
            eip name
        :type eip_name: string

        :param hostname:
            hostname
        :type hostname: string

        :param auto_seq_suffix:
            The parameter to specify whether name and hostname order suffixes are automatically generated
        :type auto_seq_suffix: boolean

        :param is_open_hostname_domain:
            The parameter to specify whether hostname domain is automatically generated
        :type is_open_hostname_domain: boolean

        :param relation_tag:
            The parameter to specify whether the instance related to existing tags
        :type relation_tag: boolean

        :param is_open_ipv6:
            is_open_ipv6
        :type is_open_ipv6: boolean

        :param enterprise_security_group_id:
            enterprise_security_group_id
        :type enterprise_security_group_id: string

        :param security_group_ids:
            security_group_ids
        :type security_group_ids: list<string>

        :param enterprise_security_group_ids:
            enterprise_security_group_ids
        :type enterprise_security_group_ids: list<string>

        :param kunlunCard:
            kunlunCard
        :type kunlunCard: string

        :param isomerismCard:
            type of isomerismCard, including kunlunCard, fpgaCard, gpuCard
        :type isomerismCard: string

        :param file_systems:
        :type file_systems:list<bcc_model.FileSystemModel>

        :param user_data:
        :type user_data: string

        :param is_open_hosteye:
        :type is_open_hosteye: boolean

        :param deletion_protection:
        :type deletion_protection: int

        :param res_group_id:
            The optional parameter to specify the resGroupId of the instance
        :type res_group_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        	   /instanceNclientTokencpuCountmemoryCapacityInGBimageIdbillingspeceipNamehostnameautoSeqSuffixisOpenHostnameDomainrelationTag
isOpenIpv6c                 S      g | ]}|j qS r   __dict__.0Zfile_systemr   r   r   
<listcomp>h      z-BccClient.create_instance.<locals>.<listcomp>fileSystemsuserDataZisOpenHosteyedeletionProtectioninstanceTyper   rootDiskSizeInGbrootDiskStorageTypecreateCdsListnetworkCapacityInMbpspurchaseCountname	adminPasszoneNamesubnetIdsecurityGroupIdenterpriseSecurityGroupIdsecurityGroupIdsenterpriseSecurityGroupIdsgpuCardr!   	cardCountfpgaCard
kunlunCardisomerismCardautoRenewTimemonthautoRenewTimeUnitephemeralDisksdedicatedHostIddeployIdbidModelbidPrice	keypairIdinternetChargeTypeaspIdrequestTokenc                 S   r0   r   r1   r4   tagr   r   r   r5     r6   tagsinternalIps
resGroupIdcdsAutoRenewr   r   generate_client_token#default_billing_to_purchase_createdr2   r   credentialssecret_access_keyr	   r   r   POSTjsondumps);r   r   r   r    instance_typer(   create_cds_listroot_disk_size_in_gbroot_disk_storage_typeephemeral_disksdedicate_host_idauto_renew_time_unitauto_renew_time	deploy_id	bid_model	bid_pricekey_pair_idcds_auto_renewinternet_charge_typeinternal_ipsrequest_tokenasp_idr[   network_capacity_in_mbpspurchase_countrI   r@   
admin_pass	zone_name	subnet_idsecurity_group_idrH   rJ   r)   eip_namer+   auto_seq_suffixis_open_hostname_domainrelation_tagis_open_ipv6enterprise_security_group_idsecurity_group_idsenterprise_security_group_idsrK   rL   file_systems	user_dataZis_open_hosteyedeletion_protectionres_group_idclient_tokenr   r   r   r   file_system_listrd   cipher_admin_passtag_listr   r   r   create_instanceN   s    ~




















zBccClient.create_instance)r   r   dedicated_host_idr    c                 C   s   d}i }|du rt  |d< n||d< ||||d}|dur!||d< |dkr)||d< |dur1||d< |	dur9|	|d	< |
durA|
|d
< |durS| jjj}t||}||d< | jtj|t	|||dS )2  
        Create a Instance from dedicatedHost with the specified options.
        You must fill the field of clientToken,which is especially for keeping idempotent.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param cpu_count:
            The specified number of cpu core to create the instance,
            is less than or equal to the remain of dedicated host.
        :type cpu_count: int

        :param memory_capacity_in_gb:
            The capacity of memory to create the instance,
            is less than or equal to the remain of dedicated host.
        :type memory_capacity_in_gb: int

        :param image_id:
            The id of image, list all available image in BccClient.list_images.
        :type image_id: string

        :param dedicated_host_id:
            The id of dedicated host, we can locate the instance in specified dedicated host.
        :type dedicated_host_id: string

        :param ephemeral_disks:
            The optional list of ephemeral volume detail info to create.
        :type ephemeral_disks: list<bcc_model.EphemeralDisk>

        :param purchase_count:
            The number of instance to buy, the default value is 1.
        :type purchase_count: int

        :param name:
            The optional parameter to desc the instance that will be created.
        :type name: string

        :param admin_pass:
            The optional parameter to specify the password for the instance.
            If specify the adminPass,the adminPass must be a 8-16 characters String
            which must contains letters, numbers and symbols.
            The symbols only contains "!@#$%^*()".
            The adminPass will be encrypted in AES-128 algorithm
            with the substring of the former 16 characters of user SecretKey.
            If not specify the adminPass, it will be specified by an random string.
            See more detail on
            https://bce.baidu.com/doc/BCC/API.html#.7A.E6.31.D8.94.C1.A1.C2.1A.8D.92.ED.7F.60.7D.AF
        :type admin_pass: string

        :param subnet_id:
            The optional parameter to specify the id of subnet from vpc, optional param
             default value is default subnet from default vpc
        :type subnet_id: string

        :param security_group_id:
            The optional parameter to specify the securityGroupId of the instance
            vpcId of the securityGroupId must be the same as the vpcId of subnetId
            See more detail through listSecurityGroups method
        :type security_group_id: string

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r"   Nr#   r%   r&   r'   rQ   rP   r   r?   r@   rC   rD   rA   r_   
ra   r   rc   rd   r	   r   r   re   rf   rg   )r   r   r   r    r   rl   rz   r@   r{   r}   r~   r   r   r   r   r   rd   r   r   r   r   ;create_instance_from_dedicated_host_with_encrypted_password  s6   N

zEBccClient.create_instance_from_dedicated_host_with_encrypted_passwordc                 C   s   d}i }|du rt  |d< n||d< ||||d}|dur!||d< |dkr)||d< |dur1||d< |dur9||d	< |	durA|	|d
< |
durI|
|d< | jtj|t|||dS )r   r"   Nr#   r   rP   r   r?   r@   rA   rC   rD   r_   ra   r   r   re   rf   rg   )r   r   r   r    r   rl   rz   r@   r{   r}   r~   r   r   r   r   r   r   r   r   #create_instance_from_dedicated_host)  s2   Nz-BccClient.create_instance_from_dedicated_hostc3           :      C   s  d}3i }4|!du rt  |4d< n|!|4d< |du rt}||||jd}5|&dur(|&|5d< |'dur0|'|5d< |(dur8|(|5d< |)dur@|)|5d< |*durH|*|5d	< |+durP|+|5d
< |,durX|,|5d< |%dur`|%|5d< |-durh|-|5d< |1durp|1|5d< |2durdd |2D }6|6|5d< |dur||5d< |dkr||5d< |dur||5d< |dur||5d< |dkr||5d< |dkr||5d< |dur||5d< |dur| jjj}7t||7}8|8|5d< |dur||5d< |dur||5d< |dur||5d< |.dur|.|5d< |0dur|0|5d< |dur||5d < |d!kr|nd!|5d"< | dur| |5d#< |d!kr|nd!|5d"< |dkr"||5d$< |du r,d%|5d&< n||5d&< |	dur9|	|5d'< |
durB|
|5d(< |durK||5d)< |durT||5d*< |dur]||5d+< |durf||5d,< |duro||5d-< |durx||5d.< |dur||5d/< |durd0d |D }9|9|5d1< |dur||5d2< ||5d3< |#dur|#|5d4< |$dur|$|5d5< |/dur|/|5d6< | jtj	|3t
|5|4|"d7S )8a   
        Create a bcc Instance with the specified options.
        You must fill the field of clientToken,which is especially for keeping idempotent.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param instance_type:
            The specified Specification to create the instance,
            See more detail on
            https://cloud.baidu.com/doc/BCC/API.html#InstanceType
        :type instance_type: string

        :param cpu_count:
            The parameter to specified the cpu core to create the instance.
        :type cpu_count: int

        :param memory_capacity_in_gb:
            The parameter to specified the capacity of memory in GB to create the instance.
        :type memory_capacity_in_gb: int

        :param image_id:
            The id of image, list all available image in BccClient.list_images.
        :type image_id: string

        :param billing:
            Billing information.
        :type billing: bcc_model.Billing

        :param create_cds_list:
            The optional list of volume detail info to create.
        :type create_cds_list: list<bcc_model.CreateCdsModel>

        :param network_capacity_in_mbps:
            The optional parameter to specify the bandwidth in Mbps for the new instance.
            It must among 0 and 200, default value is 0.
            If it's specified to 0, it will get the internal ip address only.
        :type network_capacity_in_mbps: int

        :param purchase_count:
            The number of instance to buy, the default value is 1.
        :type purchase_count: int

        :param name:
            The optional parameter to desc the instance that will be created.
        :type name: string

        :param admin_pass:
            The optional parameter to specify the password for the instance.
            If specify the adminPass,the adminPass must be a 8-16 characters String
            which must contains letters, numbers and symbols.
            The symbols only contains "!@#$%^*()".
            The adminPass will be encrypted in AES-128 algorithm
            with the substring of the former 16 characters of user SecretKey.
            If not specify the adminPass, it will be specified by an random string.
            See more detail on
            https://bce.baidu.com/doc/BCC/API.html#.7A.E6.31.D8.94.C1.A1.C2.1A.8D.92.ED.7F.60.7D.AF
        :type admin_pass: string

        :param zone_name:
            The optional parameter to specify the available zone for the instance.
            See more detail through list_zones method
        :type zone_name: string

        :param subnet_id:
            The optional parameter to specify the id of subnet from vpc, optional param
             default value is default subnet from default vpc
        :type subnet_id: string

        :param security_group_id:
            The optional parameter to specify the securityGroupId of the instance
            vpcId of the securityGroupId must be the same as the vpcId of subnetId
            See more detail through listSecurityGroups method
        :type security_group_id: string

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :param fpgaCard:
            specify the fpgaCard info of creating FPGA instance,
            see all of supported fpga card type at baidubce.services.bcc.fpga_card_type
        :type gpuCard: string

        :param gpuCard:
            specify the gpuCard info of creating GPU instance,
            see all of supported gpu card type at baidubce.services.bcc.gpu_card_type
        :type gpuCard: string

        :param cardCount:
            The parameter to specify the card count for creating GPU/FPGA instance
        :type cardCount: int

        :param root_disk_size_in_gb:
            The parameter to specify the root disk size in GB.
            The root disk excludes the system disk, available is 40-500GB.
        :type root_disk_size_in_gb: int

        :param root_disk_storage_type:
            The parameter to specify the root disk storage type.
            Default use of HP1 cloud disk.
        :type root_disk_storage_type: string

        :param ephemeral_disks:
            The optional list of ephemeral volume detail info to create.
        :type ephemeral_disks: list<bcc_model.EphemeralDisk>

        :param dedicate_host_id
            The parameter to specify the dedicate host id.
        :type dedicate_host_id: string

        :param auto_renew_time_unit
            The parameter to specify the unit of the auto renew time.
            The auto renew time unit can be "month" or "year".
            The default value is "month".
        :type auto_renew_time_unit: string

        :param auto_renew_time
            The parameter to specify the auto renew time, the default value is 0.
        :type auto_renew_time: string

        :param tags
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :param deploy_id
            The parameter to specify the id of the deploymentSet.
        :type deploy_id: string

        :param bid_model
            The parameter to specify the bidding model.
            The bidding model can be "market" or "custom".
        :type bid_model: string

        :param bid_price
            The parameter to specify the bidding price.
            When the bid_model is "custom", it works.
        :type bid_price: string

        :param key_pair_id
            The parameter to specify id of the keypair.
        :type key_pair_id: string

        :param asp_id
            The parameter to specify id of the asp.
        :type asp_id: string

        :param request_token
            The parameter to specify the request token which will make the request idempotent.
        :type request_token: string

        :param internet_charge_type
            The parameter to specify the internet charge type.
            See more detail on
            https://cloud.baidu.com/doc/BCC/API.html#InternetChargeType
        :type internet_charge_type: string

        :param internal_ips
            The parameter to specify the internal ips.
        :type internal_ips: list<string>

        :param cds_auto_renew
            The parameter to specify whether the cds is auto renew or not.
            The default value is false.
        :type cds_auto_renew: boolean

        :param spec
            The parameter to specify Specification to create the instance.
        :type spec: string

        :param user_data
            The parameter to specify instance custom data.
        :type spec: string

        :param hostname:
        :type spec: string

        :param auto_seq_suffix:
        :type spec: boolean

        :param is_open_hostname_domain:
        :type spec: boolean

        :param spec_id:
        :type spec: string

        :param relation_tag:
        :type spec: boolean

        :param is_open_ipv6:
        :type spec: boolean

        :param deletion_protection:
        :type spec: int

        :param eip_name:
        :type eip_name: string

        :param isomerismCard:
        :type isomerismCard: string

        :param enterprise_security_group_id:
        :type enterprise_security_group_id: string

        :param security_group_ids:
            security_group_ids
        :type security_group_ids: list<string>

        :param res_group_id:
            The optional parameter to specify the resGroupId of the instance
        :type res_group_id: string

        :param enterprise_security_group_ids:
            enterprise_security_group_ids
        :type enterprise_security_group_ids: list<string>

        :param file_systems:
        :type file_systems: list<bcc_model.FileSystemModel>

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/bidNr#   r$   r+   r,   r-   specIdr.   r/   r9   r*   rE   rL   c                 S   r0   r   r1   r3   r   r   r   r5     r6   z4BccClient.create_instance_of_bid.<locals>.<listcomp>r7   r:   r   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rF   rG   rH   r!   rI   rJ   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   c                 S   r0   r   r1   rY   r   r   r   r5     r6   r[   r\   r^   r)   r8   r]   r_   r`   ):r   r   r   r    rh   r(   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   r[   ry   rz   rI   r@   r{   r|   r}   r~   rH   rJ   r   r   r)   r   r   r+   r   r   spec_idr   r   r   r   r   r   r   rL   r   r   r   r   r   rd   r   r   r   r   r   create_instance_of_bid  s    s




















z BccClient.create_instance_of_bidc                 C   s  d}i }|dur||d< |dur||d< |dur||d< |dur$||d< |dur,||d< |dur4||d< |dur<||d	< |durD||d
< |	durL|	|d< |
durT|
|d< |dur\||d< |durd||d< |durl||d< |durt||d< |dur|||d< |dur||d< | j tj|||dS )aC
  
        Return a list of instances owned by the authenticated user.

        :param marker:
            The optional parameter marker specified in the original request to specify
            where in the results to begin listing.
            Together with the marker, specifies the list result which listing should begin.
            If the marker is not specified, the list result will listing from the first one.
        :type marker: string

        :param max_keys:
            The optional parameter to specifies the max number of list result to return.
            The default value is 1000.
        :type max_keys: int

        :param internal_ip:
            The identified internal ip of instance.
        :type internal_ip: string

        :param dedicated_host_id:
            get instance list filtered by id of dedicated host
        :type dedicated_host_id: string

        :param zone_name:
            get instance list filtered by name of available zone
        :type zone_name: string

        :param instance_ids:
            filter instance list with multiple instance ids join by ','
        :type instance_ids: string

        :param instance_names:
            filter instance list with multiple instance names join by ','
        :type instance_names: string

        :param cds_ids:
            filter instance list with multiple cds ids join by ','
        :type cds_ids: string

        :param deployset_ids:
            filter instance list with multiple deployset ids join by ','
        :type deployset_ids: string

        :param security_group_ids:
            filter instance list with multiple securityGroup ids join by ','
        :type security_group_ids: string

        :param payment_timing:
            filter instance list with multiple type of paymentTiming join by ','
        :type payment_timing: string

        :param status:
            filter instance list with multiple instance status join by ','
        :type status: string

        :param tags:
            filter instance list with multiple tags join by ',', the format of tag can be :
            tagKey:tagValue or tagKey
        :type tags: string

        :param vpc_id:
            filter instance list with vpc id, the parameter should be used with private_ips
        :type vpc_id: string

        :param private_ips:
            filter instance list with multiple private ips join by ',', the parameter should be used with
            vpc_id
        :type private_ips: string

        :param auto_renew:
        :type auto_renew: boolean

        :return:
        :rtype baidubce.bce_response.BceResponse
        r"   NmarkermaxKeys
internalIprQ   rB   instanceIdsZinstanceNamesZcdsIdsZdeploysetIdsrF   paymentTimingstatusr[   vpcId
privateIpsZ	autoRenewr_   r   r   GET)r   r   max_keysinternal_ipr   r|   instance_idsZinstance_namesZcds_idsZdeployset_idsr   payment_timingr   r[   vpc_idprivate_ipsZ
auto_renewr   r   r   r   r   r   list_instances  sF   OzBccClient.list_instances)instance_idc                 C   s8   |j dd}d| }i }|r||d< | jtj|||dS )  
        Get the detail information of specified instance.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param contains_failed:
            The optional parameters to get the failed message.If true, it means get the failed message.
        :type contains_failed: boolean

        :return:
        :rtype baidubce.bce_response.BceResponse
        utf-8encoding   /instance/%scontainsFailedr_   encoder   r   r   r   r   Zcontains_failedr   r   r   r   r   r   get_instanceg  s   zBccClient.get_instancec                 C   .   t |}d| }ddi}| jtj|||dS )a  
        Starting the instance owned by the user.
        You can start the instance only when the instance is Stopped,
        otherwise, it's will get 409 errorCode.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param instance_id: id of instance proposed to start
        :type instance_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   startNr_   )r   convert_to_bytesr   r   PUT)r   r   r   r   r   r   r   r   start_instance  s
   
zBccClient.start_instancec                 C   @   t |}d| }||d}ddi}| jtj|t|||dS )a  
        Stopping the instance owned by the user.
        You can stop the instance only when the instance is Running,
        otherwise, it's will get 409 errorCode.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param force_stop:
            The optional parameter to stop the instance forcibly.If true,
            it will stop the instance just like power off immediately
            and it may result in losing important data which have not been written to disk.
        :type force_stop: boolean

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   )	forceStopstopWithNoChargestopNr_   r   r   r   r   r   rf   rg   )r   r   
force_stopr   r   r   r   r   r   r   r   stop_instance  s   
zBccClient.stop_instancec                 C   >   t |}d| }d|i}ddi}| jtj|t|||dS )a  
        Rebooting the instance owned by the user.
        You can reboot the instance only when the instance is Running,
        otherwise, it's will get 409 errorCode.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param force_stop:
            The optional parameter to stop the instance forcibly.If true,
            it will stop the instance just like power off immediately
            and it may result in losing important data which have not been written to disk.
        :type force_stop: boolean

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   rebootNr_   r   )r   r   r   r   r   r   r   r   r   r   reboot_instance  s   
zBccClient.reboot_instancec                 C   sL   d}d|i}|dur||d< |dur||d< i }| j tj|t|||dS )z
        batch_add_ip
        :param instance_id:
        :param private_ips:
        :param secondary_private_ip_address_count:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/batchAddIp
instanceIdNr   ZsecondaryPrivateIpAddressCountr_   r   r   r   rf   rg   )r   r   r   Z"secondary_private_ip_address_countr   r   r   r   r   r   r   batch_add_ip  s   zBccClient.batch_add_ip)r   r   c                 C   s.   d}||d}i }| j tj|t|||dS )zi
        :param instance_id:
        :param private_ips:
        :param config:
        :return:
        s   /instance/batchDelIp)r   r   r_   r   )r   r   r   r   r   r   r   r   r   r   batch_delete_ip  s   zBccClient.batch_delete_ip)r   r{   c           	      C   sR   t |}| jjj}t||}d| }d|i}ddi}| jtj|t	
|||dS )a  
        Modifying the password of the instance.
        You can change the instance password only when the instance is Running or Stopped ,
        otherwise, it's will get 409 errorCode.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param admin_pass:
            The new password to update.
            The adminPass will be encrypted in AES-128 algorithm
            with the substring of the former 16 characters of user SecretKey.
        :type admin_pass: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   rA   Z
changePassNr_   r   r   r   rc   rd   r	   r   r   r   rf   rg   )	r   r   r{   r   rd   r   r   r   r   r   r   r   modify_instance_password  s   


z"BccClient.modify_instance_password)r   r@   c                 C   r   )a  
        Modifying the special attribute to new value of the instance.
        You can reboot the instance only when the instance is Running or Stopped ,
        otherwise, it's will get 409 errorCode.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param name:
            The new value for instance's name.
        :type name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r@   modifyAttributeNr_   r   )r   r   r@   r   r   r   r   r   r   r   modify_instance_attributes)     
z$BccClient.modify_instance_attributes)r   descc                 C   r   )a  
        Modifying the description of the instance.
        You can reboot the instance only when the instance is Running or Stopped ,
        otherwise, it's will get 409 errorCode.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param desc:
            The new value for instance's description.
        :type name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   Z
modifyDescNr_   r   )r   r   r   r   r   r   r   r   r   r   modify_instance_descG  r   zBccClient.modify_instance_desc)r   r    c                 C   sr   t |}d| }d|i}|dur||d< |dur'| jjj}t||}	|	|d< ddi}
| jtj|t	
||
|dS )a  
        Rebuilding the instance owned by the user.
        After rebuilding the instance,
        all of snapshots created from original instance system disk will be deleted,
        all of customized images will be saved for using in the future.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param image_id:
            The id of the image which is used to rebuild the instance.
        :type image_id: string

        :param admin_pass:
            The admin password to login the instance.
            The admin password will be encrypted in AES-128 algorithm
            with the substring of the former 16 characters of user SecretKey.
            See more detail on
            https://bce.baidu.com/doc/BCC/API.html#.7A.E6.31.D8.94.C1.A1.C2.1A.8D.92.ED.7F.60.7D.AF
        :type admin_pass: string

        :param key_pair_id:
            key_pair_id or admin_pass is required for rebuild instance.
        :type key_pair_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r'   NrU   rA   Zrebuildr_   r   )r   r   r    r{   rs   r   r   r   rd   r   r   r   r   r   rebuild_instancee  s   
#

zBccClient.rebuild_instancec                 C   $   t |}d| }| jtj||dS )a  
        Releasing the instance owned by the user.
        Only the Postpaid instance or Prepaid which is expired can be released.
        After releasing the instance,
        all of the data will be deleted.
        all of volumes attached will be auto detached, but the volume snapshots will be saved.
        all of snapshots created from original instance system disk will be deleted,
        all of customized images created from original instance system disk will be reserved.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   r   r   r   r   DELETEr   r   r   r   r   r   r   release_instance  s   
zBccClient.release_instance)r   r   r   c	                 C   s   t |}d| }	||d}
|dur||
d< |dur||
d< |dur&||
d< d}|du r3dt d}nd|d}| jtj|	t|
||dS )	a  
        Resizing the instance owned by the user.
        The Prepaid instance can not be downgrade.
        Only the Running/Stopped instance can be resized, otherwise, it's will get 409 errorCode.
        After resizing the instance,it will be reboot once.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param cpu_count:
            The parameter of specified the cpu core to resize the instance.
        :type cpu_count: int

        :param memory_capacity_in_gb:
            The parameter of specified the capacity of memory in GB to resize the instance.
        :type memory_capacity_in_gb: int

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :param live_resize:
        :type live_resize: boolean

        :param gpu_card_count:
        :type gpu_card_count: int

        :param ephemeral_disk_in_gb:
        :type ephemeral_disk_in_gb: int

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   )r%   r&   NZ
liveResizeZgpuCardCountZephemeralDiskInGbresizer#   r_   r   r   ra   r   r   r   rf   rg   )r   r   r   r   Zlive_resizeZgpu_card_countZephemeral_disk_in_gbr   r   r   r   r   r   r   r   resize_instance  s,   
/zBccClient.resize_instance)r   r~   c                 C   r   )aZ  
        Binding the instance to specified securitygroup.

        :param instance_id:
            The id of the instance.
        :type instance_id: string

        :param securitygroup_id:
            The id of the securitygroup.
        :type securitygroup_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   rD   bindNr_   r   r   r   r~   r   r   r   r   r   r   r   bind_instance_to_security_group     
z)BccClient.bind_instance_to_security_groupc                 C   r   )aT  
        Unbinding the instance from securitygroup.

        :param instance_id:
            The id of the instance.
        :type instance_id: string

        :param securitygroup_id:
            The id of the securitygroup.
        :type securitygroup_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   rD   unbindNr_   r   r   r   r   r   #unbind_instance_from_security_group  r   z-BccClient.unbind_instance_from_security_group)r   r[   c                 C   L   t |}d| }dd |D }d|i}ddi}| jtj|t|||dS )b
        :param instance_id:
        :param tags:
        :param config:
        :return:
           /instance/%s/tagc                 S   r0   r   r1   rY   r   r   r   r5   ;  r6   z3BccClient.bind_instance_to_tags.<locals>.<listcomp>
changeTagsr   Nr_   r   r   r   r[   r   r   r   r   r   r   r   r   bind_instance_to_tags0     
	zBccClient.bind_instance_to_tagsc                 C   r   )r   r   c                 S   r0   r   r1   rY   r   r   r   r5   P  r6   z7BccClient.unbind_instance_from_tags.<locals>.<listcomp>r   r   Nr_   r   r   r   r   r   unbind_instance_from_tagsE  r   z#BccClient.unbind_instance_from_tagsc                 C   r   )a	  
        Getting the vnc url to access the instance.
        The vnc url can be used once.

        :param instance_id:
            The id of the instance.
        :type instance_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/%s/vncr   r   r   r   r   r   r   r   r   r   get_instance_vncZ  s   
zBccClient.get_instance_vncc           	      C   sx   t |}d| }|du rt}d|ji}d}|du r!dt d}nd|d}|dur.||d< | jtj|t	|||dS )ae  
        PurchaseReserved the instance with fixed duration.
        You can not purchaseReserved the instance which is resizing.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param instance_id:
            The id of the instance.
        :type instance_id: string

        :param billing:
            Billing information.
        :type billing: bcc_model.Billing

        :param related_renew_flag:
            Detailed information see: https://cloud.baidu.com/doc/BCC/s/6jwvyo0q2#relatedrenewflag
        :type related_renew_flag: string

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   Nr(   ZpurchaseReservedr#   ZrelatedRenewFlagr_   
r   r   $default_billing_to_purchase_reservedr2   ra   r   r   r   rf   rg   )	r   r   r(   Zrelated_renew_flagr   r   r   r   r   r   r   r   purchase_reserved_instancek  s&   
%z$BccClient.purchase_reserved_instancec                 C      d}| j tj||dS )a  
        The interface will be deprecated in the future,
        we suggest to use triad (instanceType, cpuCount, memoryCapacityInGB) to specified the instance configuration.
        Listing all of specification for instance resource to buy.
        See more detail on
        https://bce.baidu.com/doc/BCC/API.html#.E5.AE.9E.E4.BE.8B.E5.A5.97.E9.A4.90.E8.A7.84.E6.A0.BC

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/specr   r   r   r   r   r   r   r   list_instance_specs  s   zBccClient.list_instance_specs)cds_size_in_gbhp1c                 C   s8  d}i }|du rt  |d< n||d< |du rt}||jd}|dur&||d< |dur.||d< |dur6||d< |
dur>|
|d< |durF||d	< |durN||d
< |durV||d< |duredd |D }||d< |durn|j|d< |durv||d< |	dur~|	|d< |dur||d< |dur||d< | jtj|t|||dS )a~
  
        Create a volume with the specified options.
        You can use this method to create a new empty volume by specified options
        or you can create a new volume from customized volume snapshot but not system disk snapshot.
        By using the cdsSizeInGB parameter you can create a newly empty volume.
        By using snapshotId parameter to create a volume form specific snapshot.

        :param cds_size_in_gb:
            The size of volume to create in GB.
            By specifying the snapshotId,
            it will create volume from the specified snapshot and the parameter cdsSizeInGB will be ignored.
        :type cds_size_in_gb: int

        :param billing:
            Billing information.
        :type billing: bcc_model.Billing

        :param purchase_count:
            The optional parameter to specify how many volumes to buy, default value is 1.
            The maximum to create for one time is 5.
        :type purchase_count: int

        :param storage_type:
            The storage type of volume, see more detail in
            https://bce.baidu.com/doc/BCC/API.html#StorageType
        :type storage_type: menu{'hp1', 'std1'}

        :param zone_name:
            The optional parameter to specify the available zone for the volume.
            See more detail through list_zones method
        :type zone_name: string

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :param instance_id:
        :type instance_id: string

        :param encrypt_key:
        :type encrypt_key: string

        :param name:
        :type name: string

        :param description:
        :type description: string

        :param renew_time_unit:
        :type renew_time_unit: string

        :param renew_time:
        :type renew_time: int

        :param cluster_id:
            cds cluster id
        :type cluster_id: string

        :param relation_tag:
        :type relation_tag: boolean

        :param tags:
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :param auto_snapshot_policy:
            The optional auto snapshot policy to be bonded.
        :type auto_snapshot_policy: bcc_model.AutoSnapshotPolicyModel

        :return:
        :rtype baidubce.bce_response.BceResponse
           /volumeNr#   )ZcdsSizeInGBr(   r?   storageTyperB   renewTimeUnit	renewTime	clusterIdr.   c                 S   r0   r   r1   rY   r   r   r   r5   %  r6   z9BccClient.create_volume_with_cds_size.<locals>.<listcomp>r[   autoSnapshotPolicyr@   description
encryptKeyr   r_   ra   rb   r2   r   r   re   rf   rg   )r   r   r(   rz   storage_typer|   r   encrypt_keyr@   r   renew_time_unit
renew_time
cluster_idr   r[   auto_snapshot_policyr   r   r   r   r   r   r   r   r   create_volume_with_cds_size  P   U
z%BccClient.create_volume_with_cds_size)snapshot_idc                 C   s8  d}i }|du rt  |d< n||d< |du rt}||jd}|dur&||d< |dur.||d< |dur6||d< |dur>||d< |durF||d	< |durN||d
< |durV||d< |duredd |D }||d< |durn|j|d< |	durv|	|d< |
dur~|
|d< |dur||d< |dur||d< | jtj|t|||dS )ak
  
        Create a volume with the specified options.
        You can use this method to create a new empty volume by specified options
        or you can create a new volume from customized volume snapshot but not system disk snapshot.
        By using the cdsSizeInGB parameter you can create a newly empty volume.
        By using snapshotId parameter to create a volume form specific snapshot.

        :param snapshot_id:
            The id of snapshot.
            By specifying the snapshotId,
            it will create volume from the specified snapshot and the parameter cdsSizeInGB will be ignored.
        :type snapshot_id: string

        :param billing:
            Billing information.
        :type billing: bcc_model.Billing

        :param purchase_count:
            The optional parameter to specify how many volumes to buy, default value is 1.
            The maximum to create for one time is 5.
        :type purchase_count: int

        :param storage_type:
            The storage type of volume, see more detail in
            https://bce.baidu.com/doc/BCC/API.html#StorageType
        :type storage_type: menu{'hp1', 'std1'}

        :param zone_name:
            The optional parameter to specify the available zone for the volume.
            See more detail through list_zones method
        :type zone_name: string

        :param instance_id:
        :type instance_id: string

        :param encrypt_key:
        :type encrypt_key: string

        :param name:
        :type name: string

        :param description:
        :type description: string

        :param renew_time_unit:
        :type renew_time_unit: string

        :param renew_time:
        :type renew_time: int

        :param cluster_id:
            cds cluster id
        :type cluster_id: string

        :param relation_tag:
        :type relation_tag: boolean

        :param tags:
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :param auto_snapshot_policy:
            The optional auto snapshot policy to be bonded.
        :type auto_snapshot_policy: bcc_model.AutoSnapshotPolicyModel

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   Nr#   )
snapshotIdr(   r?   r   rB   r   r   r   r.   c                 S   r0   r   r1   rY   r   r   r   r5     r6   z<BccClient.create_volume_with_snapshot_id.<locals>.<listcomp>r[   r   r@   r   r   r   r_   r   )r   r  r(   rz   r   r|   r   r   r   r@   r   r   r   r  r   r[   r  r   r   r   r   r   r   r   r   create_volume_with_snapshot_id4  r  z(BccClient.create_volume_with_snapshot_idc           	      C   sl   d}i }|dur||d< |dur||d< |dur||d< |dur$||d< |dur,||d< | j tj|||dS )	af  
        Listing volumes owned by the authenticated user.

        :param instance_id:
            The id of instance. The optional parameter to list the volume.
            If it's specified,only the volumes attached to the specified instance will be listed.
        :type instance_id: string

        :param zone_name:
            The name of available zone. The optional parameter to list volumes
        :type zone_name: string

        :param marker:
            The optional parameter marker specified in the original request to specify
            where in the results to begin listing.
            Together with the marker, specifies the list result which listing should begin.
            If the marker is not specified, the list result will listing from the first one.
        :type marker: string

        :param max_keys:
            The optional parameter to specifies the max number of list result to return.
            The default value is 1000.
        :type max_keys: int

        :param cluster_id:
        :type cluster_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   Nr   rB   r   r   r   r_   r   )	r   r   r|   r   r   r  r   r   r   r   r   r   list_volumes  s   !zBccClient.list_volumes)	volume_idc                 C   r   )z
        Get the detail information of specified volume.

        :param volume_id:
            The id of the volume.
        :type volume_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        
   /volume/%sr   r   r   r	  r   r   r   r   r   
get_volume     
zBccClient.get_volume)r	  r   c                 C   r   )ad  
        Attaching the specified volume to a specified instance.
        You can attach the specified volume to a specified instance only
        when the volume is Available and the instance is Running or Stopped,
        otherwise, it's will get 409 errorCode.

        :param volume_id:
            The id of the volume which will be attached to specified instance.
        :type volume_id: string

        :param instance_id:
            The id of the instance which will be attached with a volume.
        :type instance_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r
  r   attachNr_   r   r   r	  r   r   r   r   r   r   r   r   attach_volume     
zBccClient.attach_volumec                 C   r   )aM  
        Detaching the specified volume from a specified instance.
        You can detach the specified volume from a specified instance only
        when the instance is Running or Stopped ,
        otherwise, it's will get 409 errorCode.

        :param volume_id:
            The id of the volume which will be attached to specified instance.
        :type volume_id: string

        :param instance_id:
            The id of the instance which will be attached with a volume.
        :type instance_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r
  r   detachNr_   r   r  r   r   r   detach_volume  r  zBccClient.detach_volumec                 C   r   )a  
        Releasing the specified volume owned by the user.
        You can release the specified volume only
        when the instance is among state of  Available/Expired/Error,
        otherwise, it's will get 409 errorCode.

        :param volume_id:
            The id of the volume which will be released.
        :type volume_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r
  r   r   r  r   r   r   release_volume0  s   
zBccClient.release_volume)r	  new_cds_sizec           	      C   sj   t |}d| }d|i}|dur||d< d}|du r"dt d}nd|d}| jtj|t|||dS )a  
        Resizing the specified volume with newly size.
        You can resize the specified volume only when the volume is Available,
        otherwise, it's will get 409 errorCode.
        The prepaid volume can not be downgrade.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_volume.

        :param volume_id:
            The id of volume which you want to resize.
        :type volume_id: string

        :param new_cds_size:
            The new volume size you want to resize in GB.
        :type new_cds_size: int

        :param new_volume_type:
            detail information see: https://cloud.baidu.com/doc/BCC/s/6jwvyo0q2#storagetype
        :type new_volume_type: string

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r
  ZnewCdsSizeInGBNZnewVolumeTyper   r_   r   )	r   r	  r  Znew_volume_typer   r   r   r   r   r   r   r   resize_volumeC  s"   
$zBccClient.resize_volume)r	  r  c                 C   r   )aG  
        Rollback the volume with the specified volume snapshot.
        You can rollback the specified volume only when the volume is Available,
        otherwise, it's will get 409 errorCode.
        The snapshot used to rollback must be created by the volume,
        otherwise,it's will get 404 errorCode.
        If rolling back the system volume,the instance must be Running or Stopped,
        otherwise, it's will get 409 errorCode.After rolling back the
        volume,all the system disk data will erase.

        :param volume_id:
            The id of volume which will be rollback.
        :type volume_id: string

        :param snapshot_id:
            The id of snapshot which will be used to rollback the volume.
        :type snapshot_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r
  r  rollbackNr_   r   )r   r	  r  r   r   r   r   r   r   r   rollback_volume|  s   
zBccClient.rollback_volumec                 C   sh   t |}d| }|du rt}d|ji}d}|du r!dt d}nd|d}| jtj|t	|||dS )a  
        PurchaseReserved the instance with fixed duration.
        You can not purchaseReserved the instance which is resizing.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_volume.

        :param volume_id:
            The id of volume which will be renew.
        :type volume_id: string

        :param billing:
            Billing information.
        :type billing: bcc_model.Billing

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r
  Nr(   r   r_   r   )r   r	  r(   r   r   r   r   r   r   r   r   purchase_reserved_volume  s"   
 z"BccClient.purchase_reserved_volume)r	  cds_namer   c                 C   sN   t |}d| }d|i}|dur||d< ddi}| jtj|t|||dS )z
        :param volume_id:
        :type volume_id: string

        :param cds_name:
        :type cds_name:string

        :param desc:
        :type desc: string

        :return:
        r
  ZcdsNameNr   modifyr_   r   )r   r	  r  r   r   r   r   r   r   r   r   modify_volume_Attribute  s   
z!BccClient.modify_volume_Attributec                 C   sL   t |}d| }|du rt}d|ji}ddi}| jtj|t|||dS )zc
        :param volume_id:
        :param billing:
        :param config:
        :return:
        r
  Nr(   ZmodifyChargeTyper_   )	r   r   r   r2   r   r   r   rf   rg   )r   r	  r(   r   r   r   r   r   r   r   modify_volume_charge_type  s   
z#BccClient.modify_volume_charge_type)
image_namer   c           
      C   sj   d}d}|du rdt  i}nd|i}||d}	|dur||	d< |dur'||	d< | jtj|t|	||dS )a  
        Creating a customized image which can be used for creating instance.
        You can create an image from an instance with this method.
        While creating an image from an instance, the instance must be Running or Stopped,
        otherwise, it's will get 409 errorCode.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_image.

        :param image_name:
            The name for the image that will be created.
            The name length from 1 to 65,only contains letters,digital and underline.
        :type image_name: string

        :param instance_id:
            The optional parameter specify the id of the instance which will be used to create the new image.
            When instanceId and snapshotId are specified ,only instanceId will be used.
        :type instance_id: string

        :param encrypt_key:
        :type encrypt_key: string

        :param relate_cds:
        :type relate_cds: boolean

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
           /imageNr#   )	imageNamer   r   Z	relateCdsr_   r   )
r   r  r   r   Z
relate_cdsr   r   r   r   r   r   r   r   create_image_from_instance_id	  s"   -z'BccClient.create_image_from_instance_id)r  r  c           	      C   Z   d}i }|du rt  |d< n||d< ||d}|dur||d< | jtj|t|||dS )a  
        Creating a customized image which can be used for creating instance.
        You can create an image from an snapshot with tihs method.
        You can create the image only from system snapshot.
        While creating an image from a system snapshot,the snapshot must be Available,
        otherwise, it's will get 409 errorCode.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_image.

        :param image_name:
            The name for the image that will be created.
            The name length from 1 to 65,only contains letters,digital and underline.
        :type image_name: string

        :param snapshot_id:
            The optional parameter specify the id of the snapshot which will be used to create the new image.
            When instanceId and snapshotId are specified ,only instanceId will be used.
        :type snapshot_id: string

        :param encrypt_key:
        :type encrypt_key: string

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r  Nr#   )r   r  r   r_   r   )	r   r  r  r   r   r   r   r   r   r   r   r   create_image_from_snapshot_idR	  s   *z'BccClient.create_image_from_snapshot_idAllc                 C   sP   d}d|i}|dur||d< |dur||d< |dur||d< | j tj|||dS )a>  
        Listing images owned by the authenticated user.

        :param image_type:
            The optional parameter to filter image to list.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#ImageType"
        :type image_type: menu{'All', System', 'Custom', 'Integration'}

        :param marker:
            The optional parameter marker specified in the original request to specify
            where in the results to begin listing.
            Together with the marker, specifies the list result which listing should begin.
            If the marker is not specified, the list result will listing from the first one.
        :type marker: string

        :param max_keys:
            The optional parameter to specifies the max number of list result to return.
            The default value is 1000.
        :type max_keys: int

        :param image_name:
            The optional parameter to query specified custom image by image name.
        :type image_name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r  Z	imageTypeNr   r   r   r_   r   )r   Z
image_typer   r   r  r   r   r   r   r   r   list_images	  s   zBccClient.list_images)r    c                 C   r   )z
        Get the detail information of specified image.

        :param image_id:
            The id of image.
        :type image_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        	   /image/%sr   r   r   r    r   r   r   r   r   	get_image	  r  zBccClient.get_imagec                 C   r   )a*  
        Deleting the specified image.
        Only the customized image can be deleted,
        otherwise, it's will get 403 errorCode.

        :param image_id:
            The id of image.
        :type image_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r&  r   r   r'  r   r   r   delete_image	     
zBccClient.delete_image)r    r@   destRegionsc                 C   r   )z{
        :param image_id:
        :param name:
        :param destRegions:
        :param config:
        :return:
        r&  )r@   Z
destRegionZ
remoteCopyNr_   r   r   r   r   re   rf   rg   )r   r    r@   r+  r   r   r   r   r   r   r   remote_copy_image	  s   
zBccClient.remote_copy_imagec                 C   r   )J
        :param image_id:
        :param config:
        :return:
        r&  ZcancelRemoteCopyNr_   )r   r   r   r   re   )r   r    r   r   r   r   r   r   cancle_remote_copy_image	  s
   
	z"BccClient.cancle_remote_copy_imagec                 C   Z   t |}d| }i }|dur||d< |dur||d< ddi}| jtj|t|||dS )}
        :param image_id:
        :param account:
        :param account_id:
        :param config:
        :return:
        r&  Naccount	accountIdsharer_   r,  r   r    r2  Z
account_idr   r   r   r   r   r   r   share_image
     
zBccClient.share_imagec                 C   r0  )r1  r&  Nr2  r3  Zunsharer_   r,  r5  r   r   r   unshare_image 
  r7  zBccClient.unshare_imagec                 C   r   )r.  s   /image/%s/sharedUsersr   r   r'  r   r   r   list_shared_user<
     
	zBccClient.list_shared_user)r   c                 C   s*   d}|}d|i}| j tj|t||dS )zN
        :param instance_ids:
        :param config:
        :return:
        s	   /image/osr   r   r   r   re   rf   rg   )r   r   r   r   instance_id_listr   r   r   r   list_osI
  s
   	zBccClient.list_os)r	  snapshot_namec                 C   sx   d}d}|du rdt  i}nd|i}||d}	|dur||	d< |dur.dd |D }
|
|	d< | jtj|t|	||d	S )
a  
        Creating snapshot from specified volume.
        You can create snapshot from system volume and CDS volume.
        While creating snapshot from system volume,the instance must be Running or Stopped,
        otherwise, it's will get 409 errorCode.
        While creating snapshot from CDS volume, the volume must be InUs or Available,
        otherwise, it's will get 409 errorCode.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_snapshot.

        :param volume_id:
            The id which specify where the snapshot will be created from.
            If you want to create an snapshot from a customized volume, a id of the volume will be set.
            If you want to create an snapshot from a system volume, a id of the instance will be set.
        :type volume_id: string

        :param snapshot_name:
            The name for the snapshot that will be created.
            The name length from 1 to 65,only contains letters,digital and underline.
        :type snapshot_name: string

        :param desc:
            The optional parameter to describe the information of the new snapshot.
        :type desc: string

        :param tags:
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        	   /snapshotNr#   )volumeIdZsnapshotNamer   c                 S   r0   r   r1   rY   r   r   r   r5   
  r6   z-BccClient.create_snapshot.<locals>.<listcomp>r[   r_   r   )r   r	  r>  r   r[   r   r   r   r   r   r   r   r   r   create_snapshotY
  s$   2zBccClient.create_snapshotc                 C   h   d}d}|dus|dus|duri }|dur||d< |dur"||d< |dur*||d< | j tj|||dS )a  
        List snapshots

        :param marker:
            The optional parameter marker specified in the original request to specify
            where in the results to begin listing.
            Together with the marker, specifies the list result which listing should begin.
            If the marker is not specified, the list result will listing from the first one.
        :type params: string

        :param max_keys:
            The optional parameter to specifies the max number of list result to return.
            The default value is 1000.
        :type params: int

        :param volume_id:
            The id of the volume.
        :type volume_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r?  Nr   r   r@  r_   r   )r   r   r   r	  r   r   r   r   r   r   list_snapshots
  s   zBccClient.list_snapshotsc                 C   r   )z
        Get the detail information of specified snapshot.

        :param snapshot_id:
            The id of snapshot.
        :type snapshot_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
           /snapshot/%sr   r   r   r  r   r   r   r   r   get_snapshot
  r  zBccClient.get_snapshotc                 C   r   )ah  
        Deleting the specified snapshot.
        Only when the snapshot is CreatedFailed or Available,the specified snapshot can be deleted.
        otherwise, it's will get 403 errorCode.

        :param snapshot_id:
            The id of snapshot.
        :type snapshot_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        rD  r   r   rE  r   r   r   delete_snapshot
  r*  zBccClient.delete_snapshotr@   rulesc                 C   s   d}d}	|du rdt  i}	nd|i}	dd |D }
||
d}|dur&||d< |dur.||d< |dur=d	d |D }||d
< | jtj|t||	|dS )a  
        Creating a newly SecurityGroup with specified rules.

        :param name:
            The name of SecurityGroup that will be created.
        :type name: string

        :param rules:
            The list of rules which define how the SecurityGroup works.
        :type rules: list<bcc_model.SecurityGroupRuleModel>

        :param vpc_id:
            The optional parameter to specify the id of VPC to SecurityGroup
        :type vpc_id: string

        :param desc:
            The optional parameter to describe the SecurityGroup that will be created.
        :type desc: string

        :param tags:
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
           /securityGroupNr#   c                 S   r0   r   r1   )r4   ruler   r   r   r5     r6   z3BccClient.create_security_group.<locals>.<listcomp>rH  r   r   c                 S   r0   r   r1   rY   r   r   r   r5   (  r6   r[   r_   r   )r   r@   rI  r   r   r   r[   r   r   r   Z	rule_listr   r   r   r   r   create_security_group
  s*   -zBccClient.create_security_groupc                 C   \   d}i }|dur||d< |dur||d< |dur||d< |dur$||d< | j tj|||dS )a  
        Listing SecurityGroup owned by the authenticated user.

        :param instance_id:
            The id of instance. The optional parameter to list the SecurityGroup.
            If it's specified,only the SecurityGroup related to the specified instance will be listed
        :type instance_id: string

        :param vpc_id:
            filter by vpcId, optional parameter
        :type vpc_id: string

        :param marker:
            The optional parameter marker specified in the original request to specify
            where in the results to begin listing.
            Together with the marker, specifies the list result which listing should begin.
            If the marker is not specified, the list result will listing from the first one.
        :type marker: string

        :param max_keys:
            The optional parameter to specifies the max number of list result to return.
            The default value is 1000.
        :type max_keys: int

        :return:
        :rtype baidubce.bce_response.BceResponse
        rJ  Nr   r   r   r   r_   r   )r   r   r   r   r   r   r   r   r   r   r   list_security_groups-  s   
zBccClient.list_security_groups)r~   c                 C   r   )z
        Deleting the specified SecurityGroup.

        :param security_group_id:
            The id of SecurityGroup that will be deleted.
        :type security_group_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
           /securityGroup/%sr   r   )r   r~   r   r   r   r   r   delete_security_groupX  r  zBccClient.delete_security_group)r~   rK  c                 C   \   t |}d| }ddi}|du rt |d< n||d< d|ji}| jtj|t|||dS )a  
        authorize a security group rule to the specified security group

        :param security_group_id:
            The id of SecurityGroup that will be authorized.
        :type security_group_id: string

        :param rule:
            security group rule detail.
            Through protocol/portRange/direction/sourceIp/sourceGroupId, we can confirmed only one rule.
        :type rule: bcc_model.SecurityGroupRuleModel

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        rO  ZauthorizeRule Nr#   rK  r_   	r   r   ra   r2   r   r   r   rf   rg   r   r~   rK  r   r   r   r   r   r   r   r   authorize_security_group_ruleh  s   
z'BccClient.authorize_security_group_rulec                 C   rQ  )a  
        revoke a security group rule from the specified security group
        :param security_group_id:
            The id of SecurityGroup that will be revoked.
        :type security_group_id: string
        :param rule:
            security group rule detail.
            Through protocol/portRange/direction/sourceIp/sourceGroupId, we can confirmed only one rule.
        :type rule: bcc_model.SecurityGroupRuleModel
        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string
        :return:
        :rtype baidubce.bce_response.BceResponse
        rO  Z
revokeRulerR  Nr#   rK  r_   rS  rT  r   r   r   revoke_security_group_rule  s   
z$BccClient.revoke_security_group_rulec                 C   r   )zd
        Get zone detail list within current region
        :param config:
        :return:
        s   /zoner   r   r   r   r   r   
list_zones  s   zBccClient.list_zones)asp_nametime_pointsrepeat_week_daysretention_daysc           
      C   sN   d}d}|du rdt  i}nd|i}||||d}	| jtj|t|	||dS )z
        :param asp_name:
        :param time_points:
        :param repeat_week_days:
        :param retention_days:
        :param client_token:
        :param config:
        :return:
           /aspNr#   )r@   
timePointsrepeatWeekdaysretentionDaysr_   r   )
r   rX  rY  rZ  r[  r   r   r   r   r   r   r   r   
create_asp  s   zBccClient.create_asp)rx   
volume_idsc                 C   r   )c
        :param asp_id:
        :param volume_ids:
        :param config:
        :return:
           /asp/%s	volumeIdsr  Nr_   r   r   rx   ra  r   r   r   r   r   r   r   
attach_asp     
zBccClient.attach_aspc                 C   r   )rb  rc  rd  r  Nr_   r   re  r   r   r   
detach_asp  rg  zBccClient.detach_asp)rx   c                 C   r   zH
        :param asp_id:
        :param config:
        :return:
        rc  r   r   r   rx   r   r   r   r   r   
delete_asp  r:  zBccClient.delete_aspc                 C   s   d}d}|dus|dus|dus|duri }|dur||d< |dur&||d< |dur.||d< |dur6||d< | j tj|||dS )z
        :param marker:
        :param max_keys:
        :param asp_name:
        :param volume_name:
        :param config:
        :return:
        r\  Nr   r   ZaspNameZ
volumeNamer_   r   )r   r   r   rX  Zvolume_namer   r   r   r   r   r   	list_asps$  s   	 zBccClient.list_aspsc                 C   r   ri  r   rj  r   r   r   get_asp;     
zBccClient.get_asp)keypair_namec                 C   s2   d}||d}ddi}| j tj|t|||dS )zk
        :param keypair_name:
        :param keypair_desc:
        :param config:
        :return:
           /keypair)r@   r   createNr_   r;  )r   ro  keypair_descr   r   r   r   r   r   r   create_keypairF  s   zBccClient.create_keypair)ro  
public_keyc                 C   sB   d}||d}|dur||d< ddi}| j tj|t|||dS )z
        :param keypair_name:
        :param keypair_desc:
        :param public_key:
        :param config:
        :return:
        rp  )r@   Z	publicKeyNr   importr_   r   )r   ro  rr  rt  r   r   r   r   r   r   r   import_keypair\  s   zBccClient.import_keypairc                 C   rB  )za
        :param marker:
        :param max_keys:
        :param config:
        :return:
        rp  Nr   r   r@   r_   r   )r   r   r   r@   r   r   r   r   r   r   list_keypairsx  s   zBccClient.list_keypairs)
keypair_idc                 C   r   zL
        :param keypair_id:
        :param config:
        :return:
           /keypair/%sr   r   r   rx  r   r   r   r   r   get_keypair  rn  zBccClient.get_keypair)rx  r   c                 C   r   )i
        :param keypair_id:
        :param instance_ids:
        :param config:
        :return:
        rz  r   r  Nr_   r   r   rx  r   r   r   r   r   r   r   r   attach_keypair     
zBccClient.attach_keypair)rx  r   c                 C   r   )r}  rz  r   r  Nr_   r   r~  r   r   r   detach_keypair  r  zBccClient.detach_keypairc                 C   r   ry  r   r{  r   r   r   delete_keypair  s   

zBccClient.delete_keypair)rx  ro  c                 C   r   )zi
        :param keypair_id:
        :param keypair_name:
        :param config:
        :return:
        rz  r@   renameNr_   r   )r   rx  ro  r   r   r   r   r   r   r   rename_keypair     
zBccClient.rename_keypair)rx  rr  c                 C   r   )zi
        :param keypair_id:
        :param keypair_desc:
        :param config:
        :return:
        rz  r   Z
updateDescNr_   r   )r   rx  rr  r   r   r   r   r   r   r   update_keypair_desc  r  zBccClient.update_keypair_desc)cluster_size_in_gbPrepaid   rN   c                 C   s   d}i }|dur||d< |du rt  |d< n||d< tj|||d}||||jd}|
dur2|
|d< |dur:||d< |durB||d	< |	durJ|	|d
< | jtj|t|||dS )z(
        create_volume_cluster.
           /volume/clusterNZuuidFlagr#   )r   reservationLengthreservationTimeUnit)ZclusterSizeInGBr   r?   r(   rB   clusterNamer   r   r_   )	ra   r   Billingr2   r   r   re   rf   rg   )r   r  rz   r   cluster_namer   reservation_lengthreservation_time_unitr   r   r|   Z	uuid_flagr   r   r   r   r(   r   r   r   r   create_volume_cluster  s0   zBccClient.create_volume_clusterc                 C   rM  )z&
        list_volume_cluster.
        r  Nr  rB   r   r   r_   r   )r   r  r|   r   r   r   r   r   r   r   r   list_volume_cluster+  s   zBccClient.list_volume_cluster)r  c                 C   r   )z$
        Get cluster detail
           /volume/cluster/%sr   r   )r   r  r   r   r   r   r   get_volume_cluster=  s   
zBccClient.get_volume_cluster)r  new_cluster_sizec                 C   sZ   t |}d| }d|i}d}|du rdt d}nd|d}| jtj|t|||dS )z'
        resize_volume_cluster
        r  ZnewClusterSizeInGBNr   r_   r   )r   r  r  r   r   r   r   r   r   r   r   resize_volume_clusterF  s   
zBccClient.resize_volume_clusterc           
      C   sj   t |}d| }tj||d}d|ji}d}	|du r"dt d}	nd|d}	| jtj|t	
||	|dS )z&
        renew_volume_cluster
        r  )r  r  r(   Nr   r_   )r   r   r   r  r2   ra   r   r   r   rf   rg   )
r   r  r  r  r   r   r   r(   r   r   r   r   r   renew_volume_cluster^  s$   
zBccClient.renew_volume_clusterc           	      C   sV   t |}d}|||d}d}|du rdt i}nd|i}| jtj|t|||dS )z*
        autoRenew_volume_cluster
        s   /volume/cluster/autoRenew)r   r   r   Nr#   r_   r   r   ra   r   r   re   rf   rg   )	r   r  r   r   r   r   r   r   r   r   r   r   autoRenew_volume_clusterz  s   
z"BccClient.autoRenew_volume_clusterc                 C   sR   t |}d}d|i}d}|du rdt i}nd|i}| jtj|t|||dS )z1
        cancel_autoRenew_volume_cluster
        s   /volume/cluster/cancelAutoRenewr   Nr#   r_   r  )r   r  r   r   r   r   r   r   r   r   cancel_autoRenew_volume_cluster  s   
z)BccClient.cancel_autoRenew_volume_clusterc	                 C   s   d}	i }
|dur||
d< |dur||
d< |dur||
d< |dur$||
d< |dur,||
d< |dur4||
d< |dur<||
d	< | j tj|	t|
|d
S )a\  
        Lists recycled instances.

        :param marker:
            The optional parameter marker specified in the original request to specify
            where in the results to begin listing.
            Together with the marker, specifies the list result which listing should begin.
            If the marker is not specified, the list result will listing from the first one.
        :type marker: string

        :param max_keys:
            The optional parameter to specifies the max number of list result to return.
            The default value is 1000.
        :type max_keys: int

        :param instance_id:
            The identified of instance to specifies one instance.
        :type instance_id: string

        :param name:
            The name of instance to specifies one instance.
        :type name: string

        :param payment_timing:
            The payment timing of instance order values: [prepay/postpay].
        :type payment_timing: string

        :param recycle_begin:
            The begintime of the recycled instances date range. FORMAT: yyyy-MM-dd'T'HH:mm:ss'Z'
        :type recycle_begin: string

        :param recycle_end:
            The endtime of the recycled instances date range. FORMAT: yyyy-MM-dd'T'HH:mm:ss'Z'
        :type recycle_end: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /recycle/instanceNr   r   r   r@   r   ZrecycleBeginZ
recycleEnd)r   r   r;  )r   r   r   r   r@   r   Zrecycle_beginZrecycle_endr   r   r   r   r   r   list_recycled_instances  s"   (z!BccClient.list_recycled_instances)r)   r    c&           ,      C   s  d}&i }'|$du rt  |'d< n|$|'d< |du rt}|||jd}(|dkr'||(d< |dur/||(d< |dur<dd	 |D |(d
< |dkrD||(d< |durL||(d< |
dkrT|
|(d< |dur\||(d< |durd||(d< |durl||(d< |durt||(d< |dur| jjj})t||)}*|*|(d< |dur||(d< |dur||(d< |dur||(d< |dur||(d< |dur||(d< |dur||(d< |dkr||(d< |du rd|(d< n||(d< |durdd	 |D |(d< |!dur|!|(d< |"dur|"|(d< |#dur|#|(d < |dur||(d!< | dur| |(d"< |dur
||(d#< |	dur|	|(d$< |dur||(d%< |dur%||(d&< |dur.||(d'< |dur>d(d	 |D }+|+|(d)< ||(d*< | jtj	|&t
|(|'|%d+S ),a\  
        Create a bcc Instance with the specified options.
        You must fill the field of clientToken,which is especially for keeping idempotent.
        This is an asynchronous interface,
        you can get the latest status by BccClient.get_instance.

        :param spec:
            The specification of the BBC package.
        :type spec: string

        :param image_id:
            The id of image, list all available image in BccClient.list_images.
        :type image_id: string

        :param billing:
            Billing information.
        :type billing: bcc_model.Billing

        :param create_cds_list:
            The optional list of volume detail info to create.
        :type create_cds_list: list<bcc_model.CreateCdsModel>

        :param network_capacity_in_mbps:
            The optional parameter to specify the bandwidth in Mbps for the new instance.
            It must among 0 and 200, default value is 0.
            If it's specified to 0, it will get the internal ip address only.
        :type network_capacity_in_mbps: int

        :param purchase_count:
            The number of instance to buy, the default value is 1.
        :type purchase_count: int

        :param name:
            The optional parameter to desc the instance that will be created.
        :type name: string

        :param admin_pass:
            The optional parameter to specify the password for the instance.
            If specify the adminPass,the adminPass must be a 8-16 characters String
            which must contains letters, numbers and symbols.
            The symbols only contains "!@#$%^*()".
            The adminPass will be encrypted in AES-128 algorithm
            with the substring of the former 16 characters of user SecretKey.
            If not specify the adminPass, it will be specified by an random string.
            See more detail on
            https://bce.baidu.com/doc/BCC/API.html#.7A.E6.31.D8.94.C1.A1.C2.1A.8D.92.ED.7F.60.7D.AF
        :type admin_pass: string

        :param zone_name:
            The optional parameter to specify the available zone for the instance.
            See more detail through list_zones method
        :type zone_name: string

        :param subnet_id:
            The optional parameter to specify the id of subnet from vpc, optional param
             default value is default subnet from default vpc
        :type subnet_id: string

        :param security_group_id:
            The optional parameter to specify the securityGroupId of the instance
            vpcId of the securityGroupId must be the same as the vpcId of subnetId
            See more detail through listSecurityGroups method
        :type security_group_id: string

        :param enterprise_security_group_id:
            enterprise_security_group_id
        :type enterprise_security_group_id: string

        :param security_group_ids:
            security_group_ids
        :type security_group_ids: list<string>

        :param enterprise_security_group_ids:
            enterprise_security_group_ids
        :type enterprise_security_group_ids: list<string>

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :param root_disk_size_in_gb:
            The parameter to specify the root disk size in GB.
            The root disk excludes the system disk, available is 40-500GB.
        :type root_disk_size_in_gb: int

        :param root_disk_storage_type:
            The parameter to specify the root disk storage type.
            Default use of HP1 cloud disk.
        :type root_disk_storage_type: string

        :param ephemeral_disks:
            The optional list of ephemeral volume detail info to create.
        :type ephemeral_disks: list<bcc_model.EphemeralDisk>

        :param dedicate_host_id
            The parameter to specify the dedicate host id.
        :type dedicate_host_id: string

        :param auto_renew_time_unit
            The parameter to specify the unit of the auto renew time.
            The auto renew time unit can be "month" or "year".
            The default value is "month".
        :type auto_renew_time_unit: string

        :param auto_renew_time
            The parameter to specify the auto renew time, the default value is 0.
        :type auto_renew_time: int

        :param tags
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :param deploy_id
            The parameter to specify the id of the deploymentSet.
        :type deploy_id: string

        :param bid_model
            The parameter to specify the bidding model.
            The bidding model can be "market" or "custom".
        :type bid_model: string

        :param bid_price
            The parameter to specify the bidding price.
            When the bid_model is "custom", it works.
        :type bid_price: string

        :param key_pair_id
            The parameter to specify id of the keypair.
        :type key_pair_id: string

        :param asp_id
            The parameter to specify id of the asp.
        :type asp_id: string

        :param internet_charge_type
            The parameter to specify the internet charge type.
            See more detail on
            https://cloud.baidu.com/doc/BCC/API.html#InternetChargeType
        :type internet_charge_type: string

        :param cds_auto_renew
            The parameter to specify whether the cds is auto renew or not.
            The default value is false.
        :type cds_auto_renew: boolean

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instanceBySpecNr#   )r)   r'   r(   r   r;   r<   c                 S   r0   r   r1   r4   Z
create_cdsr   r   r   r5     r6   z5BccClient.create_instance_by_spec.<locals>.<listcomp>r=   r>   r*   r?   r@   r+   r,   r-   rA   rB   rC   rD   rE   rF   rG   rM   rN   rO   c                 S   r0   r   r1   )r4   Zephemeral_diskr   r   r   r5     r6   rP   rQ   rR   ZdeployIdListrS   rT   rU   rV   rW   r.   r/   c                 S   r0   r   r1   rY   r   r   r   r5     r6   r[   r^   r_   r`   ),r   r)   r    rj   rk   rl   ri   ry   r   ru   rz   r@   r+   r   r   r{   r(   r|   r}   r~   r   r   r   r   r   r[   rs   rn   ro   rt   rx   rq   rr   rm   rp   Zdeploy_id_listr   r   r   r   r   rd   r   r   r   r   r   create_instance_by_spec  s    &









z!BccClient.create_instance_by_specc                 C   sZ   ddi}|du rt  |d< n||d< t|}d| }d|i}| jtj|t|||dS )a  
            set instance auto release.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param release_time:
            The new value for instance's name.
        :type release_time: string in format yyyy-MM-dd'T'HH:mm:ss'Z'.

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        ZautoreleaseNr#   r   ZreleaseTimer   r   r   ra   r   r   r   r   r   rf   rg   )r   r   Zrelease_timer   r   r   r   r   r   r   r   auto_release_instance  s   
zBccClient.auto_release_instancec                 C   s   i }|du rt  |d< n||d< t|}d| }	i }
|dur#||
d< |dur+||
d< |dur3||
d< |dur;||
d< | jtj|	t|
||dS )	ay  
        Releasing the instance owned by the user.
        Only the Postpaid instance or Prepaid which is expired can be released.
        After releasing the instance,
        all of the data will be deleted.
        all of volumes attached will be auto detached, but the volume snapshots will be saved.
        all of snapshots created from original instance system disk will be deleted,
        all of customized images created from original instance system disk will be reserved.

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param related_release_flag:
            Release or not related resources.
        :type related_release_flag: bool

        :param delete_cds_snapshot_flag:
            Delete or not cds snapshot.
        :type delete_cds_snapshot_flag: bool

        :param delete_related_enis_flag:
            Delete or not related enis.
        :type delete_related_enis_flag: bool

        :param bcc_recycle_flag:
            Recycle or not bcc instance.
        :type bcc_recycle_flag: bool

        :return:
        :rtype baidubce.bce_response.BceResponse
        Nr#   r   relatedReleaseFlagdeleteCdsSnapshotFlagdeleteRelatedEnisFlagbccRecycleFlagr  )ra   r   r   r   r   re   rf   rg   )r   r   related_release_flagdelete_cds_snapshot_flagdelete_related_enis_flagbcc_recycle_flagr   r   r   r   r   r   r   r   'release_instance_with_related_resources  s    $
z1BccClient.release_instance_with_related_resourcesc                 C   s<   |j dd}d| }ddi}|r||d< | jtj|||dS )r   r   r   r   ZisDeploySetTr   r_   r   r   r   r   r   get_instance_with_deploy_set<     z&BccClient.get_instance_with_deploy_setc                 C   s<   |j dd}d| }ddi}|r||d< | jtj|||dS )r   r   r   r   r   Nr_   r   r   r   r   r   'get_instance_with_deploy_set_and_failedW  r  z1BccClient.get_instance_with_deploy_set_and_failed)r   r+   c           
      C   sz   ddi}|du rt  |d< n||d< t|}d| }d|i}	|dur'||	d< |dur/||	d< | jtj|t|	||dS )	a1  
        modify instance hostname

        :param instance_id:
            The id of instance.
        :type instance_id: string

        :param hostname:
            new hostname
        :type hostname: string, FORMAT ^([a-z]+)((\.|-)?[a-z0-9]+)*$

        :param reboot:
            Auto reboot the instance after hostname changed.
        :type reboot: bool

        :param is_open_hostname_domain:
            Set hostname domain opening
        :type is_open_hostname_domain: bool

        :return:
        :rtype baidubce.bce_response.BceResponse
        ZchangeHostnameNr#   r   r+   r   r-   r  r  )
r   r   r+   r   r   r   r   r   r   r   r   r   r   modify_instance_hostnamer  s   
z"BccClient.modify_instance_hostname)r<  c           	      C   sd   i }|du rt  |d< n||d< d}g }|D ]	}|d|i qd|i}| jtj|t|||dS )z
        Recovery multi instances

        :param instance_id_list:
            The id list of instances to recovery.
        :type instance_id_list: list of string

        :return:
        :rtype baidubce.bce_response.BceResponse
        Nr#   s   /instance/recoveryr   r   r  )ra   appendr   r   re   rf   rg   )	r   r<  r   r   r   r   Zlist_of_itemr   r   r   r   r   recovery_instances  s   zBccClient.recovery_instances)rh   r   memory_cap_in_gbc                 C   s  d}i }|du rt  |d< n||d< |||d}|dur ||d< |dkr(||d< |dur0||d< |dur=d	d
 |D |d< |dkrE||d< |durM||d< |	dur_| jjj}t|	|}||d< |durg||d< |duro||d< |durw||d< |dur||d< |dur||d< |
dur|
|d< |dur||d< |dur||d< |dur||d< |durdd
 |D }||d< |dur||d< | jtj|t	|||dS )aD  
        Query bid instance price in market.

        :param instance_type:
            The specified Specification to create the instance,
            See more detail on
            https://cloud.baidu.com/doc/BCC/API.html#InstanceType
        :type instance_type: string

        :param cpu_count:
            The parameter to specified the cpu core to create the instance.
        :type cpu_count: int

        :param memory_cap_in_gb:
            The parameter to specified the capacity of memory in GB to create the instance.
        :type memory_cap_in_gb: int

        :param image_id:
            The id of image, list all available image in BccClient.list_images.
        :type image_id: string

        :param create_cds_list:
            The optional list of volume detail info to create.
        :type create_cds_list: list<bcc_model.CreateCdsModel>

        :param network_cap_in_mbps:
            The optional parameter to specify the bandwidth in Mbps for the new instance.
            It must among 0 and 200, default value is 0.
            If it's specified to 0, it will get the internal ip address only.
        :type network_cap_in_mbps: int

        :param purchase_count:
            The number of instance to buy, the default value is 1.
        :type purchase_count: int

        :param name:
            The optional parameter to desc the instance that will be created.
        :type name: string

        :param admin_pass:
            The optional parameter to specify the password for the instance.
            If specify the adminPass,the adminPass must be a 8-16 characters String
            which must contains letters, numbers and symbols.
            The symbols only contains "!@#$%^*()".
            The adminPass will be encrypted in AES-128 algorithm
            with the substring of the former 16 characters of user SecretKey.
            If not specify the adminPass, it will be specified by an random string.
            See more detail on
            https://bce.baidu.com/doc/BCC/API.html#.7A.E6.31.D8.94.C1.A1.C2.1A.8D.92.ED.7F.60.7D.AF
        :type admin_pass: string

        :param zone_name:
            The optional parameter to specify the available zone for the instance.
            See more detail through list_zones method
        :type zone_name: string

        :param subnet_id:
            The optional parameter to specify the id of subnet from vpc, optional param
             default value is default subnet from default vpc
        :type subnet_id: string

        :param security_group_id:
            The optional parameter to specify the securityGroupId of the instance
            vpcId of the securityGroupId must be the same as the vpcId of subnetId
            See more detail through listSecurityGroups method
        :type security_group_id: string

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if client token is provided.
            If the clientToken is not specified by the user,
            a random String generated by default algorithm will be used.
            See more detail at
            https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
        :type client_token: string

        :param root_disk_size_in_gb:
            The parameter to specify the root disk size in GB.
            The root disk excludes the system disk, available is 40-500GB.
        :type root_disk_size_in_gb: int

        :param root_disk_storage_type:
            The parameter to specify the root disk storage type.
            Default use of HP1 cloud disk.
        :type root_disk_storage_type: string

        :param relation_tag
            Set whether the tags specified by the instance to ne queried needs
            to be associated with an existing tag key.
            The default value is false, this param is optional.
        :type relation_tag: bool

        :param tags
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :param bid_model
            The parameter to specify the bidding model.
            The bidding model can be "market" or "custom".
        :type bid_model: string

        :param bid_price
            The parameter to specify the bidding price.
            When the bid_model is "custom", it works.
        :type bid_price: string

        :param key_pair_id
            The parameter to specify id of the keypair.
        :type key_pair_id: string

        :param asp_id
            The parameter to specify id of the asp.
        :type asp_id: string

        :param internet_charge_type
            The parameter to specify the internet charge type.
            See more detail on
            https://cloud.baidu.com/doc/BCC/API.html#InternetChargeType
        :type internet_charge_type: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/bidPriceNr#   )r%   r&   r:   r'   r   r;   r<   c                 S   r0   r   r1   r  r   r   r   r5   L  r6   z4BccClient.get_bid_instance_price.<locals>.<listcomp>r=   r?   r@   rA   rB   rC   rD   rS   rT   rU   rV   rW   r.   c                 S   r0   r   r1   rY   r   r   r   r5   h  r6   r[   r>   r_   r   )r   rh   r   r  rj   rk   ri   rz   r@   r{   rs   rx   r    rq   rr   Znetwork_cap_in_mbpsr   r[   r~   r}   r|   ru   r   r   r   r   r   rd   r   r   r   r   r   get_bid_instance_price  sd    

z BccClient.get_bid_instance_pricec                 C   s8   i }|du rt  |d< n||d< d}| jtj|||dS )zi
        Get all bid flavors.

        :return:
        :rtype baidubce.bce_response.BceResponse
        Nr#   s   /instance/bidFlavorr_   )ra   r   r   re   )r   r   r   r   r   r   r   r   list_bid_flavoro  s   zBccClient.list_bid_flavor)r   r   c                 C   sX   i }|du rt  |d< n||d< |jdd}d| }d|i}| jtj|t|||dS )ak  
        Set instance deleion protection.

        :param instance_id
            The id of instance.
        :type instance_id: string

        :param deletion_protection
            The status of instance deletion protection. 1:enable, 0:disable.
        :type deletion_protection: int

        :return:
        :rtype baidubce.bce_response.BceResponse
        Nr#   r   r   s   /instance/%s/deletionProtectionr9   r_   ra   r   r   r   r   rf   rg   )r   r   r   r   r   r   r   r   r   r   r   modify_deletion_protection~  s   z$BccClient.modify_deletion_protectionc           	      C   st   i }|du rt  |d< n||d< |jdd}d| }i }|dur$||d< |dur,||d< | jtj|t|||dS )	a  
        Releasing the specified volume owned by the user.
        You can release the specified volume only
        when the instance is among state of  Available/Expired/Error,
        otherwise, it's will get 409 errorCode.

        :param volume_id:
            The id of the volume which will be released.
        :type volume_id: string

        :param auto_snapshot:
            Snapshot volume automatically. value: 'on'/'off'. Default value: 'off'.
        :type auto_snapshot: string

        :param manual_snapshot:
            Snapshot volume manually. value: 'on'/'off'. Default value: 'off'.
        :type manual_snapshot: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        Nr#   r   r   r
  ZautoSnapshotZmanualSnapshotr  )ra   r   r   r   re   rf   rg   )	r   r	  Zauto_snapshotZmanual_snapshotr   r   r   r   r   r   r   r   release_volume_new  s   zBccClient.release_volume_new)r	  r   r   c           	      C   sL   i }|du rt  |d< n||d< d}|||d}| jtj|t|||dS )a'  
        set auto_renew_cds_volume

        :param volume_id:
            The id of the volume which will be renewed.
        :type volume_id: string

        :param renew_time:
            Auto renew start time.
            Value:
                - month: 1 ~ 9
                - year: 1 ~ 3
        :type renew_time: string

        :param renew_time_unit:
            Choose automatic monthly or annual renewals. value: 'month'/'year'
        :type renew_time_unit: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        Nr#   s   /volume/autoRenew)r@  r   r   r  r   )	r   r	  r   r   r   r   r   r   r   r   r   r   auto_renew_cds_volume  s   zBccClient.auto_renew_cds_volumec                 C   sH   d}d|i}i }|du rt  |d< n||d< | jtj|t|||dS )z
        cancel_auto_renew_volume_cluster

        :param volume_id:
            The id of the volume which will be renewed.
        :type volume_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /volume/cancelAutoRenewr@  Nr#   r_   r   )r   r	  r   r   r   r   r   r   r   r   cancel_auto_renew_cds_volume  s   z&BccClient.cancel_auto_renew_cds_volume)r|   c                 C   s<   d}d|i}|du rt  |d< n||d< | jtj|||dS )z
        get_available_disk_info

        :param zone_name:
            The name of available zone for volume to use.
        :type zone_name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /volume/diskrB   Nr#   r_   ra   r   r   r   r   r|   r   r   r   r   r   r   r   get_available_disk_info  s   z!BccClient.get_available_disk_infoc           
      C      ddi}|du rt  |d< n||d< |jdd}d| }i }|dur&||d< |dur5dd	 |D }	|	|d
< | jtj|t|||dS )aP  
        bind tags to volume

        :param volume_id:
            The id of the volume which will be renewed.
        :type volume_id: string

        :param tags
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   Nr#   r   r      /volume/%s/tagr.   c                 S   r0   r   r1   rY   r   r   r   r5   0  r6   z(BccClient.tag_volume.<locals>.<listcomp>r   r_   r  
r   r	  r   r[   r   r   r   r   r   r   r   r   r   
tag_volume     zBccClient.tag_volumec           
      C   r  )aR  
        unbind tags to volume

        :param volume_id:
            The id of the volume which will be renewed.
        :type volume_id: string

        :param tags
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   Nr#   r   r   r  r.   c                 S   r0   r   r1   rY   r   r   r   r5   R  r6   z*BccClient.untag_volume.<locals>.<listcomp>r   r_   r  r  r   r   r   untag_volume5  r  zBccClient.untag_volumec           
      C   s|   d}d|i}	|du rt  |	d< n||	d< |dur||	d< |dur$||	d< |dur,||	d< |dur4||	d< | jtj||	|d	S )
a  
        list_snapshot_chain

        :param volume_id:
            The id of the volume which will be renewed.
        :type volume_id: string

        :param order
            The response list order. Value: asc/desc
        :type order: string

        :param order_by
            The response list order. Value: chainId(default)/chainSize/volumeSize
        :type order_by: string

        :param page_no
            page number. default value = 1
        :type page_no: int

        :param page_size
            page size. default value  = 1000
        :type page_size: int

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /snapshot/chainr@  Nr#   orderZorderByZpageNoZpageSizer_   r  )
r   r	  r  Zorder_byZpage_noZ	page_sizer   r   r   r   r   r   r   list_snapshot_chainW  s   zBccClient.list_snapshot_chain)chain_idc           	      C   v   ddi}|du rt  |d< n||d< |jdd}d| }i }|dur-dd |D }||d	< | jtj|t|||d
S )aV  
        bind tags to snapshot chain

        :param chain_id:
            The id of the volume which will be renewed.
        :type chain_id: string

        :param tags
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   Nr#   r   r      /snapshot/chain/%s/tagc                 S   r0   r   r1   rY   r   r   r   r5     r6   z0BccClient.tag_snapshot_chain.<locals>.<listcomp>r   r_   r  	r   r  r[   r   r   r   r   r   r   r   r   r   tag_snapshot_chain     zBccClient.tag_snapshot_chainc           	      C   r  )aX  
        unbind tags to snapshot chain

        :param chain_id:
            The id of the volume which will be renewed.
        :type chain_id: string

        :param tags
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   Nr#   r   r   r  c                 S   r0   r   r1   rY   r   r   r   r5     r6   z2BccClient.untag_snapshot_chain.<locals>.<listcomp>r   r_   r  r  r   r   r   untag_snapshot_chain  r  zBccClient.untag_snapshot_chainc                 C   s   d}i }	|du rt  |	d< n||	d< i }
|dur||
d< |dur$||
d< |dur,||
d< |dur4||
d< |dur<||
d< | jtj|t|
|	|d	S )
a  
        update asp
        Attention: Param name and asp_id can not both be none.

        :param name:
            The name of the asp.
        :type name: string

        :param asp_id:
            Identify of asp.
        :type asp_id: string

        :param time_points:
            Daily triggering time(hour of day, 0 ~ 23) of snapshot policy. e.g. [0, 6, 12, 18].
        :type time_points: list

        :param repeat_week_days:
            Weekly triggering time(day of week, 0 ~ 6, 0 means Sunday) of snapshot policy. e.g. [1, 3]
        :type repeat_week_days: list

        :param retention_days:
            Retention days of snapshot.
        :type retention_days: int

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /asp/updateNr#   r@   rW   r]  r^  r_  r_   ra   r   r   r   rf   rg   )r   r@   rx   rY  rZ  r[  r   r   r   r   r   r   r   r   
update_asp  s&   zBccClient.update_aspc	                 C   s   d}	i }
|du rt  |
d< n||
d< i }|dur||d< |dur$||d< |dur,||d< |dur4||d< |dur<||d< |durD||d	< | jtj|	t||
|d
S )a  
        Get price of instance flover by spec.
        Attention: Param spec_id and spec can not both be none.

        :param spec_id:
            Identify of the spec.
        :type spec_id: string

        :param spec:
            The name of spec.
        :type spec: string

        :param payment_timing:
            Payment timing of instance, prepay or postpay.
        :type payment_timing: string

        :param zone_name:
            Name of available zone.
        :type zone_name: string

        :param purchase_num:
            Number of purchase.
        :type purchase_num: int

        :param purchase_length:
            Reservation time.
        :type purchase_length: int

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/priceNr#   r   r)   r   rB   r?   ZpurchaseLengthr_   r   )r   r   r)   r   r|   Zpurchase_numZpurchase_lengthr   r   r   r   r   r   r   r   get_price_by_spec  s*   !zBccClient.get_price_by_specc           	      C   sz   d}i }|du rt  |d< n||d< |dur||d< |dur"||d< |dur*||d< |dur2||d< | jtj|d||d	S )
a  
        list the logicalZone from the bcc package specification.

        :param spec_id:
            Identify of the spec.
        :type spec_id: string

        :param spec:
            The name of spec.
        :type spec: string

        :param product_type:
            Payment timing of instance, prepay or postpay.
        :type product_type: string

        :param instance_type:
            The specified Specification to create the instance,
            See more detail on
            https://cloud.baidu.com/doc/BCC/API.html#InstanceType
        :type instance_type: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/flavorZonesNr#   r   r)   ZproductTyper:   s   /v1)r   r   r   r  )	r   r   r)   product_typerh   r   r   r   r   r   r   r   list_type_zones3  s   zBccClient.list_type_zonesc           
      C      d}i }|du rt  |d< n||d< i }	|dur||	d< |dur$||	d< |dur,||	d< |dur4||	d< | jtj|t|	||dS )	a  
        Change instance subnet by id.

        :param instance_id:
            Identify of the instance.
        :type instance_id: string

        :param subnet_id:
            New subnet id.
        :type subnet_id: string

        :param internal_ip:
            Ip address of internal network.
        :type internal_ip: string

        :param reboot:
        Reboot instance or not. Default value is False.
        :type reboot: bool

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /subnet/changeSubnetNr#   r   rC   r   r   r  r  
r   r   r}   r   r   r   r   r   r   r   r   r   r   instance_change_subnet^     z BccClient.instance_change_subnetc           
      C   r  )	a   
        Change instance vpc by id.

        :param instance_id:
            Identify of the instance.
        :type instance_id: string

        :param subnet_id:
            New subnet id.
        :type subnet_id: string

        :param internal_ip:
            Ip address of internal network.
        :type internal_ip: string

        :param reboot:
        Reboot instance or not. Default value is False.
        :type reboot: bool

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /vpc/changeVpcNr#   r   rC   r   r   r  r  r  r   r   r   instance_change_vpc  r  zBccClient.instance_change_vpcc                 C   H   |j dd}d| }i }|du rt |d< n||d< | jtj|||dS )z
        Change instance vpc by id.

        :param instance_id:
            Identify of the instance.
        :type instance_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   s   /eni/%sNr#   r_   r   ra   r   r   r   )r   r   r   r   r   r   r   r   r   list_instance_enis  s   zBccClient.list_instance_enisc                 C   sH   d}i }|du rt  |d< n||d< |dur||d< | jtj|||dS )z
        Change instance vpc by id.

        :param zone_name:
            Available zone name
        :type zone_name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/flavorSpecNr#   rB   r_   r  r  r   r   r   list_flavor_spec  s   zBccClient.list_flavor_specc                 C   s\   |j dd}d| }ddi}|du rt |d< n||d< d|i}| jtj|t|||dS )	a!  
        Resize instance by spec.

        :param instance_id:
            Identify of the instance.
        :type instance_id: string

        :param spec:
            The name of spec.
        :type spec: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   s   /instanceBySpec/%sr   Nr#   r)   r  r   ra   r   r   r   rf   rg   )r   r   r)   r   r   r   r   r   r   r   r   resize_instance_by_spec  s   z!BccClient.resize_instance_by_specc           
      C   s\   d}i }|du rt  |d< n||d< |||d}	|dur ||	d< | jtj|t|	||dS )a*  
        Batch rebuild instances.

        :param image_id:
            Image id for rebuild.
        :type image_id: string

        :param admin_pass:
            The password of admin.
        :type admin_pass: string

        :param instance_ids:
            Identify list of instances need to rebuild.
        :type instance_ids: list of string

        :param keypair_id:
            Set the id of the keypair to be bound. (optional param)
        :type keypair_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/rebuildNr#   )r'   rA   r   rU   r  r  )
r   r    r{   r   rx  r   r   r   r   r   r   r   r   batch_rebuild_instances  s   z!BccClient.batch_rebuild_instancesc           	      C   sl   |j dd}d| }ddi}|du rt |d< n||d< d|i}|dur(||d< | jtj|t|||d	S )
a  
        Change instance pay timing to prepaid.

        :param instance_id:
            Identify of the instance to change
        :type instance_id: string

        :param duration:
            Set the duration time of prepayment, unit:month.
        :type duration: int

        :param relation_cds:
            Set whether to chagne the associated data disk. True - change; False - no change. Default is False.
        :type relation_cds: bool

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   r   toPrepayNr#   durationZrelationCdsr  )r   ra   r   r   re   rf   rg   )	r   r   r  Zrelation_cdsr   r   r   r   r   r   r   r   change_to_prepaid%  s   zBccClient.change_to_prepaidc           
      C   s   d}i }	|du rt  |	d< n||	d< |dur||	d< |dur"||	d< |dur*||	d< |dur2||	d< |dur:||	d< | jtj||	|d	S )
a&  
        Return a list of no charge instances owned by the authenticated user.

        :param marker:
            The optional parameter marker specified in the original request to specify
            where in the results to begin listing.
            Together with the marker, specifies the list result which listing should begin.
            If the marker is not specified, the list result will listing from the first one.
        :type marker: string

        :param max_keys:
            The optional parameter to specifies the max number of list result to return.
            The default value is 1000.
        :type max_keys: int

        :param internal_ip:
            The identified internal ip of instance.
        :type internal_ip: string

        :param keypair_id:
            get instance list filtered by keypair
        :type keypair_id: string

        :param zone_name:
            get instance list filtered by name of available zone
        :type zone_name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/noChargeNr#   r   r   r   rU   rB   r_   r  )
r   r   r   r   rx  r|   r   r   r   r   r   r   r   list_instance_no_chargeH  s     z!BccClient.list_instance_no_chargec                 C   H   d}i }|du rt  |d< n||d< d|i}| jtj|t|||dS )z
        Cancel a bid order

        :param order_id:
            Identify of the order to cancel
        :type order_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/cancelBidOrderNr#   ZorderIdr  r   )r   Zorder_idr   r   r   r   r   r   r   r   cancel_bid_orderz     zBccClient.cancel_bid_orderc           	      C   L   d}i }|du rt  |d< n||d< |||d}| jtj|t|||dS )a  
        create auto renew rules for instance

        :param instance_id:
            Identify of the instance to auto renew
        :type instance_id: string

        :param renew_time_unit:
            Time unit for renew, values: 'month'/'year', default value: month
        :type renew_time_unit: string

        :param renew_time:
            renew time of year, values: 1/2/3, default value: 1
        :type renew_time: int

        :return:
        :rtype baidubce.bce_response.BceResponse
        s#   /instance/batchCreateAutoRenewRulesNr#   )r   r   r   r  r   )	r   r   r   r   r   r   r   r   r   r   r   r   batch_create_auto_renew_rules  s   z'BccClient.batch_create_auto_renew_rulesc                 C   r  )z
        delete auto renew rules for instance

        :param instance_id:
            Identify of the instance to auto renew
        :type instance_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s#   /instance/batchDeleteAutoRenewRulesNr#   r   r  r   r   r   r   r   r   r   r   r   r   r   batch_delete_auto_renew_rules  r  z'BccClient.batch_delete_auto_renew_rulesc                 C   sT   |j dd}d| }i }|du rt |d< n||d< i }| jtj|t|||dS )z
        delete auto renew rules for instance

        :param instance_id:
            Identify of the instance to delete
        :type instance_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   s   /recycle/instance/%sNr#   r  )r   ra   r   r   r   rf   rg   r  r   r   r   delete_recycled_instance  s   z"BccClient.delete_recycled_instancec           	      C   sh   d}i }|du rt  |d< n||d< |dur||d< |dur"||d< d|i}| jtj|t|||dS )a"  
        list instances by id list

        :param instance_ids:
            Identify of the instances to return info
        :type instance_ids: list of string

        :param marker:
            The optional parameter marker specified in the original request to specify
            where in the results to begin listing.
            Together with the marker, specifies the list result which listing should begin.
            If the marker is not specified, the list result will listing from the first one.
        :type marker: string

        :param max_keys:
            The optional parameter to specifies the max number of list result to return.
            The default value is 1000.
        :type max_keys: int
        
        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/listByInstanceIdNr#   r   r   r   r  r   )	r   r   r   r   r   r   r   r   r   r   r   r   list_instance_by_instance_ids  s   z'BccClient.list_instance_by_instance_idsc                 C   r  )z
        get instances delete progress

        :param instance_ids:
            Identify of the instances to return info
        :type instance_ids: list of string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/deleteProgressNr#   r   r  r   r   r   r   r   r   r   r   r   r   r   get_instance_delete_progress  r  z&BccClient.get_instance_delete_progressc                 C   s   d}i }	|du rt  |	d< n||	d< d|i}
|dur||
d< |dur&||
d< |dur.||
d< |dur6||
d< | jtj|t|
|	|d	S )
a  
        batch delete instance with related resource

        :param instance_ids:
            Identify of the instances to return info
        :type instance_ids: list of string

        :param related_release_flag:
            Release or not related resources.
        :type related_release_flag: bool

        :param delete_cds_snapshot_flag:
            Delete or not cds snapshot.
        :type delete_cds_snapshot_flag: bool

        :param delete_related_enis_flag:
            Delete or not related enis.
        :type delete_related_enis_flag: bool

        :param bcc_recycle_flag:
            Recycle or not bcc instance.
        :type bcc_recycle_flag: bool


        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/batchDeleteNr#   r   r  r  r  r  r  r   )r   r   r  r  r  r  r   r   r   r   r   r   r   r   +batch_delete_instance_with_related_resource  s    z5BccClient.batch_delete_instance_with_related_resourcec                 C   sL   d}ddi}|du rt  |d< n||d< d|i}| jtj|t|||dS )z
        batch start instance

        :param instance_ids:
            Identify of the instances to return info
        :type instance_ids: list of string

        :return:
        :rtype baidubce.bce_response.BceResponse
           /instance/batchActionr   Nr#   r   r  r  r  r   r   r   batch_start_instanceI  s   zBccClient.batch_start_instancec           	      C   sl   d}ddi}|du rt  |d< n||d< d|i}|dur ||d< |dur(||d< | jtj|t|||dS )	a  
        batch stop instance

        :param instance_ids:
            Identify of the instances to return info
        :type instance_ids: list of string

        :param force_stop:
            force stop instance
        :type force_stop: bool

        :param stop_with_no_charge:
            stop instance and stop billing
        :type stop_with_no_charge: bool

        :return:
        :rtype baidubce.bce_response.BceResponse
        r  r   Nr#   r   r   r   r  r  )	r   r   r   Zstop_with_no_charger   r   r   r   r   r   r   r   batch_stop_instancea  s   zBccClient.batch_stop_instancec           	      C   r  )a  
        get short-long id mapping by short/long id list

        :param ids:
            short id list
        :type ids: list of string

        :param id_type:
            id type
        :type id_type: string. value: short|long

        :param object_type:
            object type
        :type object_type: value: bcc

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/id/mappingNr#   )r   ZidTypeZ
objectTyper  r   )	r   ZidsZid_typeZobject_typer   r   r   r   r   r   r   r   list_id_mappings     zBccClient.list_id_mappingsc                 C   s~   d}ddi}	|du rt  |	d< n||	d< ||d}
|dur!||
d< |dur)||
d< |dur1||
d< | jtj|t|
|	|d	S )
a@  
        batch resize instance

        :param instance_ids:
            Identify of the instances to return info
        :type instance_ids: list of string

        :param spec:
            spec
        :type spec: string

        :param subnet_id:
            subnet id
        :type subnet_id: string

        :param logical_zone:
            logical zone name
        :type logical_zone: string

        :param internal_ip_v4:
            internal ip for ipv4
        :type internal_ip_v4: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instanceBatchBySpecr   Nr#   instanceIdListr)   rC   ZlogicalZoneinternalIpV4r  r  )r   r   r)   r}   logical_zoneZinternal_ip_v4r   r   r   r   r   r   r   r   batch_resize_instance  s    zBccClient.batch_resize_instancec           
      C   s~   d}ddi}|du rt  |d< n||d< ||d}	|dur!||	d< |dur)||	d< |dur1||	d< | jtj|t|	||d	S )
a  
        list available specs of resize instance in specified zone

        :param instance_ids:
            Identify of the instances to return info
        :type instance_ids: list of string

        :param spec:
            spec
        :type spec: string

        :param spec_id:
            spec id
        :type spec_id: string

        :param logical_zone:
            logical zone name
        :type logical_zone: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r"   Z
resizeListNr#   r  r   zoner  r  r   )
r   r   r)   r   r  r   r   r   r   r   r   r   r   list_available_resize_specs  s    z%BccClient.list_available_resize_specsc                 C   V   d}ddi}|du rt  |d< n||d< ddd |D i}| jtj|t|||dS )	a  
        batch change instance to prepay

        :param change_pay_timing_req_list:
            batch change req list
        :type change_pay_timing_req_list: list of PayTimingChangeReqModel

        :return:
        :rtype baidubce.bce_response.BceResponse
           /instance/batch/chargingr  Nr#   r   c                 S   r0   r   r1   r4   Zchange_pay_timing_reqr   r   r   r5     r6   z=BccClient.batch_change_instance_to_prepay.<locals>.<listcomp>r  r   r   Zchange_pay_timing_req_listr   r   r   r   r   r   r   r   batch_change_instance_to_prepay     z)BccClient.batch_change_instance_to_prepayc                 C   r  )	a  
        batch change instance to postpay

        :param change_pay_timing_req_list:
            batch change req list
        :type change_pay_timing_req_list: list of PayTimingChangeReqModel

        :return:
        :rtype baidubce.bce_response.BceResponse
        r  Z	toPostpayNr#   r   c                 S   r0   r   r1   r  r   r   r   r5   .  r6   z>BccClient.batch_change_instance_to_postpay.<locals>.<listcomp>r  r   r  r   r   r    batch_change_instance_to_postpay  r  z*BccClient.batch_change_instance_to_postpayc                 C   8   d}i }|du rt  |d< n||d< | jtj|||dS )zg
        list instance role

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/role/listNr#   r_   r  r   r   r   r   r   r   r   r   list_instance_roles2     zBccClient.list_instance_rolesc           
      C   j   d}ddi}g }|D ]	}| d|i q
|du rt |d< n||d< ||d}	| jtj|t|	||dS )a!  
        bind_instance_role

        :param instance_ids:
            instance id list
        :type instance_ids: list of string

        :param role_name:
            name of role
        :type role_name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
           /instance/roler   Nr   r#   	instancesZroleNamer  r  ra   r   r   re   rf   rg   
r   r   Z	role_namer   r   r   r   r  r   r   r   r   r   bind_instance_roleA     zBccClient.bind_instance_rolec           
      C   r  )a#  
        unbind_instance_role

        :param instance_ids:
            instance id list
        :type instance_ids: list of string

        :param role_name:
            name of role
        :type role_name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r  r   Nr   r#   r  r  r  r  r   r   r   unbind_instance_rolea  r
  zBccClient.unbind_instance_rolec           	      C   r  )a  
        add_ipv6

        :param instance_id:
            instance id
        :type instance_id: list of string

        :param ipv6_address:
            ipv6 address to bind instance
        :type ipv6_address: list of string

        :param reboot:
            reboot the instance
        :type reboot: list of string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/addIpv6Nr#   )r   Zipv6Addressr   r  r   )	r   r   ipv6_addressr   r   r   r   r   r   r   r   r   add_ipv6  r  zBccClient.add_ipv6c                 C   J   d}i }|du rt  |d< n||d< ||d}| jtj|t|||dS )a  
        delete_ipv6

        :param instance_id:
            instance id
        :type instance_id: list of string

        :param reboot:
            reboot the instance
        :type reboot: list of string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/delIpv6Nr#   )r   r   r  r   )r   r   r   r   r   r   r   r   r   r   r   delete_ipv6     zBccClient.delete_ipv6c           	      C   j   |j dd}d| }ddi}|du rt |d< n||d< dd |D }d	|i}| jtj|t|||d
S )a2  
        bind_image_to_tags

        :param image_id:
            image id
        :type image_id: list of string

        :param tags
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r      /image/%s/tagr   Nr#   c                 S   r0   r   r1   rY   r   r   r   r5     r6   z0BccClient.bind_image_to_tags.<locals>.<listcomp>r   r  r  	r   r    r[   r   r   r   r   r   r   r   r   r   bind_image_to_tags     zBccClient.bind_image_to_tagsc           	      C   r  )a4  
        unbind_image_to_tags

        :param image_id:
            image id
        :type image_id: list of string

        :param tags
            The optional list of tag to be bonded.
        :type tags: list<bcc_model.TagModel>

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   r  r   Nr#   c                 S   r0   r   r1   rY   r   r   r   r5     r6   z2BccClient.unbind_image_to_tags.<locals>.<listcomp>r   r  r  r  r   r   r   unbind_image_to_tags  r  zBccClient.unbind_image_to_tagsc	                 C   sR   d}	i }
|du rt  |
d< n||
d< ||||||d}| jtj|	t||
|dS )aI  
        import_custom_image

        :param os_name:
            name of os
        :type os_name: string

        :param os_arch:
        	archicture of os
        :type os_arch: string

        :param os_type:
            type of os
        :type os_type: string

        :param os_version:
            version of os
        :type os_version: string

        :param name:
            name of os
        :type name: string

        :param bos_url:
            boot script of os
        :type bos_url: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /image/importNr#   )ZosNameZosArchZosTypeZ	osVersionr@   ZbosUrlr  r   )r   os_nameos_archZos_type
os_versionr@   Zbos_urlr   r   r   r   r   r   r   r   import_custom_image  s   zBccClient.import_custom_imagec                 C   sb   |j dd}d| }i }|du rt |d< n||d< ddd |D i}| jtj|t|||d	S )
aI  
        create_remote_copy_snapshot

        :param snapshot_id:
            identify of snapshot
        :type snapshot_id: string

        :param dest_region_infos:
            information of destination region
        :type dest_region_infos: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   s   /snapshot/remote_copy/%sNr#   ZdestRegionInfosc                 S   r0   r   r1   )r4   Zdest_region_infor   r   r   r5   >  r6   z9BccClient.create_remote_copy_snapshot.<locals>.<listcomp>r  r  )r   r  Zdest_region_infosr   r   r   r   r   r   r   r   create_remote_copy_snapshot'  s   z%BccClient.create_remote_copy_snapshotc           	      C   st   d}i }|du rt  |d< n||d< i }|dur||d< |dur$||d< |dur,||d< | jtj|t|||dS )a}  
        create_deploy_set

        :param name:
            name of deploy set
        :type name: string

        :param strategy:
            deploy strategy HOST_HA | RACK_HA | TOR_HA
        :type strategy: string

        :param desc:
            description of deploy set
        :type desc: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/deployset/createNr#   r@   strategyr   r  r   )	r   r@   r  r   r   r   r   r   r   r   r   r   create_deploy_setB  s   zBccClient.create_deploy_setc                 C   r  )ze
        list_deploy_sets

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/deployset/listNr#   r_   r  r   r   r   r   list_deploy_setsd  r  zBccClient.list_deploy_setsc                 C   r  )z
        delete_deploy_set

        :param deploy_set_id:
            identify of deployset
        :type deploy_set_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r      /instance/deployset/%sNr#   r_   )r   ra   r   r   r   r   deploy_set_idr   r   r   r   r   r   r   delete_deploy_sets     zBccClient.delete_deploy_setc           	      C   sx   |j dd}d| }ddi}|du rt |d< n||d< i }|dur&||d< |dur.||d< | jtj|t|||d	S )
ar  
        modify_deploy_set

        :param deploy_set_id:
            identify of deployset
        :type deploy_set_id: string

        :param name:
            name of deploy set
        :type name: string

        :param desc:
            description of deploy set
        :type desc: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   r  r   Nr#   r@   r   r  r  )	r   r!  r@   r   r   r   r   r   r   r   r   r   modify_deploy_set  s   zBccClient.modify_deploy_setc                 C   r  )z
        get_deploy_set

        :param deploy_set_id:
            identify of deployset
        :type deploy_set_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   s   /deployset/%sNr#   r_   r  r   r   r   r   get_deploy_set  r#  zBccClient.get_deploy_setc           	      C   r"  )aF  
        update instance deploy relation

        :param instance_id:
            identify of instance
        :type instance_id: string

        :param deployset_id_list:
            identify list of deployset
        :type deployset_id_list: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s"   /instance/deployset/updateRelationNr#   )r   ZdeploysetIdListforcer  r   )	r   r   Zdeployset_id_listr&  r   r   r   r   r   r   r   r   update_instance_deploy  s   z BccClient.update_instance_deployc                 C   r  )aH  
        delete instance deploy relation

        :param instance_id_list:
            identify list of instance
        :type instance_id_list: string

        :param deploy_set_id:
            identify of deployset
        :type deploy_set_id: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /instance/deployset/delRelationNr#   )r  rR   r  r   )r   r<  r!  r   r   r   r   r   r   r   r   del_instance_deploy  r  zBccClient.del_instance_deployr   )NNNNNN)0NNNr   NNNNr   NNNNFNNNNNr   r!   r!   NNNNNNNNNNFFNNNNNNNNNFNNNN)Nr!   NNNNNN)/NNNr   NNNNr   NNNNFNNNNNr   r!   r!   NNNNNNNNNNNNNFFNFFNNNNNNN)NNNNNNNNNNNNNNNNN)FN)FFN)NNN)NNNNN)NNNN)Nr!   r   NNNNNNNNFNNNN)Nr!   r   NNNNNNNNNFNNN)NN)NFNN)r$  NNNN)r!   r   Nr  r  rN   NNNNNN)r  rN   NN)NNNNNNNN)#r   NNNr   NNr!   NNNNNNNNNNNNNNNNNr   NNNNNNNNN)NNNr!   NNNNNNNNNNNNNNNN)NNNNNNN)rN   r!   NN)FNN)__name__
__module____qualname____doc__r   r   r   r   r
   intbytesstrr   r   r   r   r   r   r   r   r   r   listr   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r!  r#  r%  r(  r)  r-  r/  r6  r8  r9  r=  rA  rC  rF  rG  rL  rN  rP  r   ZSecurityGroupRuleModelrU  rV  rW  r`  rf  rh  rk  rl  rm  rs  rv  rw  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r  r  r  r  r"  r$  r%  r'  r(  r   r   r   r   r   /   s
   	  oig  `t! 
"2F;~~/7!4@7*F$D+(#	#

#; z'5* 8%$!!
/
39++
+'#2!&1% 0,   /"#r   c                   C   s   t t S )z
    The default method to generate the random string for client_token
    if the optional parameter client_token is not specified by the user.
    :return:
    :rtype string
    )r/  uuiduuid4r   r   r   r   generate_client_token_by_uuid  s   r3  c                  C   s   d ttjtj d} | S )z
    The alternative method to generate the random string for client_token
    if the optional parameter client_token is not specified by the user.
    :return:
    :rtype string
    rR  $   )joinrandomsamplestringascii_lettersdigits)r   r   r   r   generate_client_token_by_random  s   r;  )%r,  
__future__r   r   rf   loggingr6  r8  r1  Zbaidubcer   Zbaidubce.authr   Zbaidubce.httpr   r   r   Zbaidubce.services.bccr   Zbaidubce.utilsr	   r
   r   	getLoggerr)  Z_loggerZFETCH_MODE_SYNCZFETCH_MODE_ASYNCZENCRYPTION_ALGORITHMr  rb   r   r   r   r3  r;  ra   r   r   r   r   <module>   s   

                                             v
