Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bucket access monitor api and modify bucket lifecycle rule #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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