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 reserved capacity api #254

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
82 changes: 49 additions & 33 deletions samples/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
$ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
Common::println("bucket $bucket created");

// Create a bucket under the reserved capacity
$id = "a1b398e6-c4e5-481b-8638-*******";
$options = array(
OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_DEEPCOLDARCHIVE,
OssClient::OSS_REDUNDANCY => OssClient::OSS_REDUNDANCY_LRS,
OssClient::OSS_RESERVED_CAPACITY_ID => $id

);
$ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PRIVATE,$options);
Common::println("bucket $bucket created");

// Check whether a bucket exists
$doesExist = $ossClient->doesBucketExist($bucket);
Common::println("bucket $bucket exist? " . ($doesExist ? "yes" : "no"));
Expand All @@ -34,6 +45,9 @@
Common::println("bucket storage class:".$info->getStorageClass()."\n");
Common::println("bucket extranet endpoint:".$info->getExtranetEndpoint()."\n");
Common::println("bucket intranet endpoint:".$info->getIntranetEndpoint()."\n");
if ($info->getReservedCapacityInstanceId() != null){
Common::println("bucket reserved capacity instance id:".$info->getReservedCapacityInstanceId()."\n");
}


// Get the bucket list
Expand Down Expand Up @@ -111,20 +125,23 @@ function doesBucketExist($ossClient, $bucket)
*/
function getBucketInfo($ossClient, $bucket)
{
try {
$info = $ossClient->getBucketInfo($bucket);
printf("bucket name:%s\n", $info->getName());
printf("bucket location:%s\n", $info->getLocation());
printf("bucket creation time:%s\n", $info->getCreateDate());
printf("bucket storage class:%s\n", $info->getStorageClass());
printf("bucket extranet endpoint:%s\n", $info->getExtranetEndpoint());
printf("bucket intranet endpoint:%s\n", $info->getIntranetEndpoint());
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
try {
$info = $ossClient->getBucketInfo($bucket);
printf("bucket name:%s\n", $info->getName());
printf("bucket location:%s\n", $info->getLocation());
printf("bucket creation time:%s\n", $info->getCreateDate());
printf("bucket storage class:%s\n", $info->getStorageClass());
printf("bucket extranet endpoint:%s\n", $info->getExtranetEndpoint());
printf("bucket intranet endpoint:%s\n", $info->getIntranetEndpoint());
if ($info->getReservedCapacityInstanceId() != null){
Common::println("bucket reserved capacity instance id:".$info->getReservedCapacityInstanceId()."\n");
}
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}


Expand All @@ -136,16 +153,15 @@ function getBucketInfo($ossClient, $bucket)
*/
function getBucketLocation($ossClient, $bucket)
{
try {
$regions = $ossClient->getBucketLocation($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}

print("bucket $bucket region: " .print_r($regions,true));

try {
$regions = $ossClient->getBucketLocation($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}

print("bucket $bucket region: " .print_r($regions,true));
}


Expand All @@ -157,15 +173,15 @@ function getBucketLocation($ossClient, $bucket)
*/
function getBucketMeta($ossClient, $bucket)
{
try {
$metas = $ossClient->getBucketMeta($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
print("bucket $bucket meta: " .print_r($metas,true));
try {
$metas = $ossClient->getBucketMeta($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
print("bucket $bucket meta: " .print_r($metas,true));
}

/**
Expand Down
6 changes: 6 additions & 0 deletions samples/BucketStat.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
Common::println("Bucket ".$bucket." cold archive storage is:".$stat->getColdArchiveStorage().PHP_EOL);
Common::println("Bucket ".$bucket." cold archive real storage is:".$stat->getColdArchiveRealStorage().PHP_EOL);
Common::println("Bucket ".$bucket." cold archive object count is:".$stat->getColdArchiveObjectCount().PHP_EOL);
Common::println("Bucket ".$bucket." deep cold archive storage is:".$stat->getDeepColdArchiveStorage().PHP_EOL);
Common::println("Bucket ".$bucket." deep cold archive real storage is:".$stat->getDeepColdArchiveRealStorage().PHP_EOL);
Common::println("Bucket ".$bucket." deep cold archive object count is:".$stat->getDeepColdArchiveObjectCount().PHP_EOL);

//******************************* For complete usage, see the following functions ****************************************************
getBucketStat($ossClient,$bucket);
Expand Down Expand Up @@ -61,5 +64,8 @@ function getBucketStat($ossClient, $bucket)
printf("Bucket ".$bucket." cold archive storage is:".$stat->getColdArchiveStorage().PHP_EOL);
printf("Bucket ".$bucket." cold archive real storage is:".$stat->getColdArchiveRealStorage().PHP_EOL);
printf("Bucket ".$bucket." cold archive object count is:".$stat->getColdArchiveObjectCount().PHP_EOL);
printf("Bucket ".$bucket." deep cold archive storage is:".$stat->getDeepColdArchiveStorage().PHP_EOL);
printf("Bucket ".$bucket." deep cold archive real storage is:".$stat->getDeepColdArchiveRealStorage().PHP_EOL);
printf("Bucket ".$bucket." deep cold archive object count is:".$stat->getDeepColdArchiveObjectCount().PHP_EOL);
print(__FUNCTION__ . ": OK" . "\n");
}
Loading