def _convert_service_properties_to_xml(logging, hour_metrics, minute_metrics, cors, target_version=None):
service_properties_element = ETree.Element('<STR_LIT>');<EOL>if logging:<EOL><INDENT>logging_element = ETree.SubElement(service_properties_element, '<STR_LIT>')<EOL>ETree.SubElement(logging_element, '<STR_LIT>').text = logging.version<EOL>ETree.SubElement(logging_element, '<STR_LIT>').text = str(logging.delete)<EOL>ETree.SubElement(logging_element, '<STR_LIT>').text = str(logging.read)<EOL>ETree.SubElement(logging_element, '<STR_LIT>').text = str(logging.write)<EOL>retention_element = ETree.SubElement(logging_element, '<STR_LIT>')<EOL>_convert_retention_policy_to_xml(logging.retention_policy, retention_element)<EOL><DEDENT>if hour_metrics:<EOL><INDENT>hour_metrics_element = ETree.SubElement(service_properties_element, '<STR_LIT>')<EOL>_convert_metrics_to_xml(hour_metrics, hour_metrics_element)<EOL><DEDENT>if minute_metrics:<EOL><INDENT>minute_metrics_element = ETree.SubElement(service_properties_element, '<STR_LIT>')<EOL>_convert_metrics_to_xml(minute_metrics, minute_metrics_element)<EOL><DEDENT>if cors is not None:<EOL><INDENT>cors_element = ETree.SubElement(service_properties_element, '<STR_LIT>')<EOL>for rule in cors:<EOL><INDENT>cors_rule = ETree.SubElement(cors_element, '<STR_LIT>')<EOL>ETree.SubElement(cors_rule, '<STR_LIT>').text = "<STR_LIT:U+002C>".join(rule.allowed_origins)<EOL>ETree.SubElement(cors_rule, '<STR_LIT>').text = "<STR_LIT:U+002C>".join(rule.allowed_methods)<EOL>ETree.SubElement(cors_rule, '<STR_LIT>').text = str(rule.max_age_in_seconds)<EOL>ETree.SubElement(cors_rule, '<STR_LIT>').text = "<STR_LIT:U+002C>".join(rule.exposed_headers)<EOL>ETree.SubElement(cors_rule, '<STR_LIT>').text = "<STR_LIT:U+002C>".join(rule.allowed_headers)<EOL><DEDENT><DEDENT>if target_version:<EOL><INDENT>ETree.SubElement(service_properties_element, '<STR_LIT>').text = target_version<EOL><DEDENT>try:<EOL><INDENT>stream = BytesIO()<EOL>ETree.ElementTree(service_properties_element).write(stream, xml_declaration=True, encoding='<STR_LIT:utf-8>', method='<STR_LIT>')<EOL><DEDENT>except:<EOL><INDENT>raise<EOL><DEDENT>finally:<EOL><INDENT>output = stream.getvalue()<EOL>stream.close()<EOL><DEDENT>return output<EOL>
<?xml version="1.0" encoding="utf-8"?>
<StorageServiceProperties>
    <Logging>
        <Version>version-number</Version>
        <Delete>true|false</Delete>
        <Read>true|false</Read>
        <Write>true|false</Write>
        <RetentionPolicy>
            <Enabled>true|false</Enabled>
            <Days>number-of-days</Days>
        </RetentionPolicy>
    </Logging>
    <HourMetrics>
        <Version>version-number</Version>
        <Enabled>true|false</Enabled>
        <IncludeAPIs>true|false</IncludeAPIs>
        <RetentionPolicy>
            <Enabled>true|false</Enabled>
            <Days>number-of-days</Days>
        </RetentionPolicy>
    </HourMetrics>
    <MinuteMetrics>
        <Version>version-number</Version>
        <Enabled>true|false</Enabled>
        <IncludeAPIs>true|false</IncludeAPIs>
        <RetentionPolicy>
            <Enabled>true|false</Enabled>
            <Days>number-of-days</Days>
        </RetentionPolicy>
    </MinuteMetrics>
    <Cors>
        <CorsRule>
            <AllowedOrigins>comma-separated-list-of-allowed-origins</AllowedOrigins>
            <AllowedMethods>comma-separated-list-of-HTTP-verb</AllowedMethods>
            <MaxAgeInSeconds>max-caching-age-in-seconds</MaxAgeInSeconds>
            <ExposedHeaders>comma-seperated-list-of-response-headers</ExposedHeaders>
            <AllowedHeaders>comma-seperated-list-of-request-headers</AllowedHeaders>
        </CorsRule>
    </Cors>
</StorageServiceProperties>