in oss2/xml_utils.py [0:0]
def to_put_inventory_configuration(inventory_config):
root = ElementTree.Element("InventoryConfiguration")
_add_text_child(root, "Id", inventory_config.inventory_id)
if inventory_config.is_enabled is not None:
_add_text_child(root, "IsEnabled", str(inventory_config.is_enabled))
if inventory_config.included_object_versions is not None:
_add_text_child(root, "IncludedObjectVersions", inventory_config.included_object_versions)
if inventory_config.inventory_filter is not None:
filter_node = ElementTree.SubElement(root, 'Filter')
if inventory_config.inventory_filter.prefix is not None:
_add_text_child(filter_node, "Prefix", inventory_config.inventory_filter.prefix)
if inventory_config.inventory_filter.last_modify_begin_time_stamp is not None:
_add_text_child(filter_node, "LastModifyBeginTimeStamp", str(inventory_config.inventory_filter.last_modify_begin_time_stamp))
if inventory_config.inventory_filter.last_modify_end_time_stamp is not None:
_add_text_child(filter_node, "LastModifyEndTimeStamp", str(inventory_config.inventory_filter.last_modify_end_time_stamp))
if inventory_config.inventory_filter.lower_size_bound is not None:
_add_text_child(filter_node, "LowerSizeBound", str(inventory_config.inventory_filter.lower_size_bound))
if inventory_config.inventory_filter.upper_size_bound is not None:
_add_text_child(filter_node, "UpperSizeBound", str(inventory_config.inventory_filter.upper_size_bound))
if inventory_config.inventory_filter.storage_class is not None:
_add_text_child(filter_node, "StorageClass", inventory_config.inventory_filter.storage_class)
if inventory_config.inventory_schedule is not None and inventory_config.inventory_schedule.frequency is not None:
schedule_node = ElementTree.SubElement(root, 'Schedule')
_add_text_child(schedule_node, "Frequency", inventory_config.inventory_schedule.frequency)
if inventory_config.optional_fields is not None:
fields_node = ElementTree.SubElement(root, 'OptionalFields')
for field in inventory_config.optional_fields:
_add_text_child(fields_node, "Field", field)
if inventory_config.inventory_destination is not None and inventory_config.inventory_destination.bucket_destination is not None:
destin_node = ElementTree.SubElement(root, 'Destination')
bucket_destin_node = ElementTree.SubElement(destin_node, 'OSSBucketDestination')
bucket_destin = inventory_config.inventory_destination.bucket_destination
if bucket_destin.account_id is not None:
_add_text_child(bucket_destin_node, "AccountId", str(bucket_destin.account_id))
if bucket_destin.role_arn is not None:
_add_text_child(bucket_destin_node, "RoleArn", bucket_destin.role_arn)
if bucket_destin.bucket is not None:
_add_text_child(bucket_destin_node, "Bucket", "acs:oss:::" + bucket_destin.bucket)
if bucket_destin.inventory_format is not None:
_add_text_child(bucket_destin_node, "Format", bucket_destin.inventory_format)
if bucket_destin.prefix is not None:
_add_text_child(bucket_destin_node, "Prefix", bucket_destin.prefix)
if bucket_destin.sse_kms_encryption is not None:
encryption_node = ElementTree.SubElement(bucket_destin_node, 'Encryption')
sse_kms_node = ElementTree.SubElement(encryption_node, 'SSE-KMS')
_add_text_child(sse_kms_node, "KeyId", bucket_destin.sse_kms_encryption.key_id)
elif bucket_destin.sse_oss_encryption is not None:
encryption_node = ElementTree.SubElement(bucket_destin_node, 'Encryption')
_add_node_child(encryption_node, 'SSE-OSS')
return _node_to_string(root)