def to_bucket_cname_configuration()

in oss2/xml_utils.py [0:0]


def to_bucket_cname_configuration(domain, cert=None):
    root = ElementTree.Element("BucketCnameConfiguration")
    cname = ElementTree.SubElement(root, 'Cname')
    _add_text_child(cname, 'Domain', domain)
    if cert is not None:
        certificate = ElementTree.SubElement(cname, 'CertificateConfiguration')
        if cert.cert_id is not None:
            _add_text_child(certificate, 'CertId', cert.cert_id)
        if cert.certificate is not None:
            _add_text_child(certificate, 'Certificate', cert.certificate)
        if cert.private_key is not None:
            _add_text_child(certificate, 'PrivateKey',cert.private_key)
        if cert.previous_cert_id is not None:
            _add_text_child(certificate, 'PreviousCertId', cert.previous_cert_id)
        if cert.force is not None:
            _add_text_child(certificate, 'Force', str(cert.force))
        if cert.delete_certificate is not None:
            _add_text_child(certificate, 'DeleteCertificate', str(cert.delete_certificate))
    return _node_to_string(root)