in sample/put_bucket_inventory.py [0:0]
def main():
args = parser.parse_args()
# Loading credentials values from the environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Using the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
if args.endpoint is not None:
cfg.endpoint = args.endpoint
client = oss.Client(cfg)
result = client.put_bucket_inventory(oss.PutBucketInventoryRequest(
bucket=args.bucket,
inventory_id=args.inventory_id,
inventory_configuration=oss.InventoryConfiguration(
included_object_versions='All',
optional_fields=oss.OptionalFields(
fields=[oss.InventoryOptionalFieldType.SIZE, oss.InventoryOptionalFieldType.LAST_MODIFIED_DATE],
),
id=args.inventory_id,
is_enabled=True,
destination=oss.InventoryDestination(
oss_bucket_destination=oss.InventoryOSSBucketDestination(
format=oss.InventoryFormatType.CSV,
account_id=args.user_id,
role_arn=args.arn,
bucket=f'acs:oss:::{args.bucket}',
prefix='aaa',
),
),
schedule=oss.InventorySchedule(
frequency=oss.InventoryFrequencyType.DAILY,
),
filter=oss.InventoryFilter(
lower_size_bound=1024,
upper_size_bound=1048576,
storage_class='ColdArchive',
prefix='aaa',
last_modify_begin_time_stamp=1637883649,
last_modify_end_time_stamp=1638347592,
),
),
))
print(f'status code: {result.status_code},'
f' request id: {result.request_id},'
)