Skip to content

Commit

Permalink
add bucket access monitor api and modify bucket lifecycle rule
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzong18 committed Sep 15, 2022
1 parent 572d0f8 commit 207027f
Show file tree
Hide file tree
Showing 26 changed files with 2,135 additions and 207 deletions.
2 changes: 2 additions & 0 deletions samples/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// Get the info of bucket
$info = $ossClient->getBucketInfo($bucket);
Common::println("bucket name:".$info->getName()."\n");
Common::println("bucket access monitor:".$info->getAccessMonitor()."\n");
Common::println("bucket location:". $info->getLocation()."\n");
Common::println("bucket creation time:".$info->getCreateDate()."\n");
Common::println("bucket storage class:".$info->getStorageClass()."\n");
Expand Down Expand Up @@ -114,6 +115,7 @@ function getBucketInfo($ossClient, $bucket)
try {
$info = $ossClient->getBucketInfo($bucket);
printf("bucket name:%s\n", $info->getName());
printf("bucket access monitor:%s",$info->getAccessMonitor()."\n");
printf("bucket location:%s\n", $info->getLocation());
printf("bucket creation time:%s\n", $info->getCreateDate());
printf("bucket storage class:%s\n", $info->getStorageClass());
Expand Down
61 changes: 61 additions & 0 deletions samples/BucketAccessMonitor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

require_once __DIR__ . '/Common.php';

use OSS\OssClient;
use OSS\Core\OssException;

$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
$bucket = Common::getBucketName();

//******************************* Simple Usage****************************************************************

// put access monitor
$status = 'Enabled';
$ossClient->putBucketAccessMonitor($bucket, $status);
printf('Put Bucket Access Monitor Success' . "\n");


// get access monitor
$status = $ossClient->getBucketAccessMonitor($bucket);
printf('Get Bucket Access Monitor Status:%s'."\n",$status);


//******************************* For complete usage, see the following functions ****************************************************
putBucketAccessMonitor($ossClient,$bucket);
getBucketAccessMonitor($ossClient,$bucket);

/**
* putBucketAccessMonitor
* @param $ossClient OssClient
* @param string $bucket bucket_name string
*/
function putBucketAccessMonitor($ossClient, $bucket)
{
try{
$status = 'Enabled'; // set Enabled to enable access monitor; set Disabled to disable access monitor
$ossClient->putBucketTransferAcceleration($bucket,$status);
printf('Put Bucket Access Monitor Success' . "\n");
} catch(OssException $e) {
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}

/**
* @param $ossClient OssClient
* @param string $bucket bucket_name
*/
function getBucketAccessMonitor($ossClient, $bucket)
{
try{
$status = $ossClient->getBucketAccessMonitor($bucket);
printf('Get Bucket Access Monitor Status:%s'."\n",$status);
} catch(OssException $e) {
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
Loading

0 comments on commit 207027f

Please sign in to comment.