diff --git a/samples/BucketAccessPoint.php b/samples/BucketAccessPoint.php
new file mode 100644
index 0000000..f85286a
--- /dev/null
+++ b/samples/BucketAccessPoint.php
@@ -0,0 +1,408 @@
+putBucketAccessPoint($bucket,$accessConfig);
+printf("Put Access Point Result Access Point Arn:%s".PHP_EOL,$result->getAccessPointArn());
+printf("Put Access Point Result Access Point Alias:%s".PHP_EOL,$result->getAlias());
+
+// Get Bucket Access Point
+$access = $ossClient->getBucketAccessPoint($bucket,$apName);
+printf("Access Point Name:%s".PHP_EOL,$access->getAccessPointName());
+printf("Access Point Bucket:%s".PHP_EOL,$access->getBucket());
+printf("Access Point Account Id:%s".PHP_EOL,$access->getAccountId());
+printf("Access Point Network Origin:%s".PHP_EOL,$access->getNetworkOrigin());
+printf("Access Point Vpc Id:%s".PHP_EOL,$access->getVpcId());
+printf("Access Point Arn:%s".PHP_EOL,$access->getAccessPointArn());
+printf("Access Point Creation Date:%s".PHP_EOL,$access->getCreationDate());
+printf("Access Point Alias:%s".PHP_EOL,$access->getAlias());
+printf("Access Point Status:%s".PHP_EOL,$access->getStatus());
+printf("Access Point Internal Endpoint:%s".PHP_EOL,$access->getInternalEndpoint());
+printf("Access Point Public Endpoint:%s".PHP_EOL,$access->getPublicEndpoint());
+
+// List Bucket Access Point
+$list = $ossClient->listBucketAccessPoint($bucket);
+printf("List Access Point Is Truncated:%s".PHP_EOL,$list->getIsTruncated());
+printf("List Access Point Next Continuation Token:%s".PHP_EOL,$list->getNextContinuationToken());
+printf("List Access Point Account Id:%s".PHP_EOL,$list->getAccountId());
+$accessPoints = $list->getAccessPoints();
+if (isset($accessPoints)){
+ foreach ($accessPoints as $access){
+ printf("Access Point Name:%s".PHP_EOL,$access->getAccessPointName());
+ printf("Access Point Bucket:%s".PHP_EOL,$access->getBucket());
+ printf("Access Point Network Origin:%s".PHP_EOL,$access->getNetworkOrigin());
+ printf("Access Point Vpc Id:%s".PHP_EOL,$access->getVpcId());
+ printf("Access Point Alias:%s".PHP_EOL,$access->getAlias());
+ printf("Access Point Status:%s".PHP_EOL,$access->getStatus());
+ }
+}
+
+
+
+// Delete Bucket Access Point
+$apName = "ap-name-01";
+$ossClient->deleteBucketAccessPoint($bucket,$apName);
+
+// Put Access Point Policy
+$policy = <<< BBBB
+{
+ "Version": "1",
+ "Statement": [{
+ "Effect": "Allow",
+ "Action": [
+ "oss:*"
+ ],
+ "Principal": [
+ "****8365787808****"
+ ],
+ "Resource": [
+ "acs:oss:ap-southeast-2:****92521021****:accesspoint/$apName",
+ "acs:oss:ap-southeast-2:****92521021****:accesspoint/$apName/object/*"
+ ]
+ }]
+}
+BBBB;
+
+$ossClient->putAccessPointPolicy($bucket,$apName,$policy);
+
+// Get Access Point Policy
+$repPolicy = $ossClient->getAccessPointPolicy($bucket,$apName);
+printf("Get Access Point Policy:%s".PHP_EOL,$repPolicy);
+
+// Delete Access Point Policy
+$ossClient->deleteAccessPointPolicy($bucket,$apName);
+
+// Put Access Point Policy By Access Point Alias
+$alias = $result->getAlias();
+$ossClient->putAccessPointPolicy($alias,$apName,$policy);
+// Get Access Point Policy By Access Point Alias
+$result = $ossClient->getAccessPointPolicy($alias,$apName);
+printf("Get Access Point Policy:%s".PHP_EOL,$result);
+
+// Delete Access Point Policy By Access Point Alias
+$ossClient->deleteAccessPointPolicy($alias,$apName);
+
+//******************************* For complete usage, see the following functions ****************************************************
+
+putBucketAccessPoint($ossClient, $bucket);
+getBucketAccessPoint($ossClient, $bucket);
+listBucketAccessPoint($ossClient, $bucket);
+deleteBucketAccessPoint($ossClient, $bucket);
+putAccessPointPolicy($ossClient, $bucket);
+getAccessPointPolicy($ossClient, $bucket);
+deleteAccessPointPolicy($ossClient, $bucket);
+putAccessPointPolicyByAlias($ossClient, $alias);
+getAccessPointPolicyByAlias($ossClient, $alias);
+deleteAccessPointPolicyByAlias($ossClient, $alias);
+
+/**
+ * Put Bucket Access Point
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $bucket Name of the bucket to create
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function putBucketAccessPoint($ossClient, $bucket)
+{
+ try {
+ $apName = "ap-name-01";
+ $networkOrigin = AccessPointConfig::VPC;
+ $vpcId = "vpc-123456789";
+ $accessConfig = new AccessPointConfig($apName,$networkOrigin,$vpcId);
+ $result = $ossClient->putBucketAccessPoint($bucket,$accessConfig);
+ printf("Put Access Point Result Access Point Arn:%s".PHP_EOL,$result->getAccessPointArn());
+ printf("Put Access Point Result Access Point Alias:%s".PHP_EOL,$result->getAlias());
+ } catch (OssException $e) {
+ printf(__FUNCTION__ . ": FAILED\n");
+ printf($e->getMessage() . "\n");
+ return;
+ }
+ print(__FUNCTION__ . ": OK" . "\n");
+}
+
+
+/**
+ * Get Bucket Access Point
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $bucket Name of the bucket to create
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function getBucketAccessPoint($ossClient, $bucket)
+{
+ try {
+ $apName = "ap-name-01";
+ $access = $ossClient->getBucketAccessPoint($bucket,$apName);
+ printf("Access Point Name:%s".PHP_EOL,$access->getAccessPointName());
+ printf("Access Point Bucket:%s".PHP_EOL,$access->getBucket());
+ printf("Access Point Account Id:%s".PHP_EOL,$access->getAccountId());
+ printf("Access Point Network Origin:%s".PHP_EOL,$access->getNetworkOrigin());
+ printf("Access Point Vpc Id:%s".PHP_EOL,$access->getVpcId());
+ printf("Access Point Arn:%s".PHP_EOL,$access->getAccessPointArn());
+ printf("Access Point Creation Date:%s".PHP_EOL,$access->getCreationDate());
+ printf("Access Point Alias:%s".PHP_EOL,$access->getAlias());
+ printf("Access Point Status:%s".PHP_EOL,$access->getStatus());
+ printf("Access Point Internal Endpoint:%s".PHP_EOL,$access->getInternalEndpoint());
+ printf("Access Point Public Endpoint:%s".PHP_EOL,$access->getPublicEndpoint());
+ } catch (OssException $e) {
+ printf(__FUNCTION__ . ": FAILED\n");
+ printf($e->getMessage() . "\n");
+ return;
+ }
+
+ print(__FUNCTION__ . ": OK" . "\n");
+}
+
+/**
+ * List Bucket Access Point
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $bucket Name of the bucket to create
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function listBucketAccessPoint($ossClient, $bucket)
+{
+ try {
+ $options = array();
+ while (true) {
+ $list = $ossClient->listBucketAccessPoint($bucket, $options);
+ printf("List Access Point Is Truncated:%s" . PHP_EOL, var_export($list->getIsTruncated(), true));
+ printf("List Access Point Next Continuation Token:%s" . PHP_EOL, $list->getNextContinuationToken());
+ printf("List Access Point Account Id:%s" . PHP_EOL, $list->getAccountId());
+ printf("List Access Point Max Keys:%s" . PHP_EOL, $list->getMaxKeys());
+ $accessPoints = $list->getAccessPoints();
+ if (isset($accessPoints)) {
+ foreach ($accessPoints as $access) {
+ printf("Access Point Name:%s" . PHP_EOL, $access->getAccessPointName());
+ printf("Access Point Bucket:%s" . PHP_EOL, $access->getBucket());
+ printf("Access Point Network Origin:%s" . PHP_EOL, $access->getNetworkOrigin());
+ printf("Access Point Vpc Id:%s" . PHP_EOL, $access->getVpcId());
+ printf("Access Point Alias:%s" . PHP_EOL, $access->getAlias());
+ printf("Access Point Status:%s" . PHP_EOL, $access->getStatus());
+ }
+ }
+
+ if ($list->getIsTruncated()) {
+ $options[OssClient::OSS_CONTINUATION_TOKEN] = $list->getNextContinuationToken();
+ } else {
+ break;
+ }
+ }
+ } catch (OssException $e) {
+ printf(__FUNCTION__ . ": FAILED\n");
+ printf($e->getMessage() . "\n");
+ return;
+ }
+
+ print(__FUNCTION__ . ": OK" . "\n");
+}
+
+
+/**
+ * Delete Bucket Access Point
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $bucket Name of the bucket to create
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function deleteBucketAccessPoint($ossClient, $bucket)
+{
+ try{
+ $apName = "ap-name-01";
+ $ossClient->deleteBucketAccessPoint($bucket,$apName);
+ printf("Delete Bucket Access Point Success!");
+ } catch(OssException $e) {
+ printf($e->getMessage() . "\n");
+ }
+ print(__FUNCTION__ . ": OK" . "\n");
+}
+
+
+/**
+ * Put Bucket Access Point
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $bucket Name of the bucket to create
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function putAccessPointPolicy($ossClient, $bucket)
+{
+ try {
+ $apName = "ap-name-01";
+ $policy = <<< BBBB
+{
+ "Version": "1",
+ "Statement": [{
+ "Effect": "Allow",
+ "Action": [
+ "oss:*"
+ ],
+ "Principal": [
+ "****8365787808****"
+ ],
+ "Resource": [
+ "acs:oss:ap-southeast-2:****92521021****:accesspoint/$apName",
+ "acs:oss:ap-southeast-2:****92521021****:accesspoint/$apName/object/*"
+ ]
+ }]
+}
+BBBB;
+
+ $ossClient->putAccessPointPolicy($bucket,$apName,$policy);
+ printf("Put Access Point Success!");
+ } catch (OssException $e) {
+ printf(__FUNCTION__ . ": FAILED\n");
+ printf($e->getMessage() . "\n");
+ return;
+ }
+ print(__FUNCTION__ . ": OK" . "\n");
+}
+
+
+/**
+ * Get Access Point Policy
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $bucket Name of the bucket to create
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function getAccessPointPolicy($ossClient, $bucket)
+{
+ try {
+ $apName = "ap-name-01";
+ $result = $ossClient->getAccessPointPolicy($bucket,$apName);
+ printf("Get Access Point Policy:%s".PHP_EOL,$result);
+ } catch (OssException $e) {
+ printf(__FUNCTION__ . ": FAILED\n");
+ printf($e->getMessage() . "\n");
+ return;
+ }
+
+ print(__FUNCTION__ . ": OK" . "\n");
+}
+
+/**
+ * Delete Access Point Policy
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $bucket Name of the bucket to create
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function deleteAccessPointPolicy($ossClient, $bucket)
+{
+ try{
+ $apName = "ap-name-01";
+ $ossClient->deleteAccessPointPolicy($bucket,$apName);
+ printf("Delete Access Point Policy Success!");
+ } catch(OssException $e) {
+ printf($e->getMessage() . "\n");
+ }
+ print(__FUNCTION__ . ": OK" . "\n");
+}
+
+/**
+ * Put Bucket Access Point By Alias
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $alias access point alias name
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function putAccessPointPolicyByAlias($ossClient, $alias)
+{
+ try {
+ $apName = "ap-name-01";
+ $policy = <<< BBBB
+{
+ "Version": "1",
+ "Statement": [{
+ "Effect": "Allow",
+ "Action": [
+ "oss:*"
+ ],
+ "Principal": [
+ "****8365787808****"
+ ],
+ "Resource": [
+ "acs:oss:ap-southeast-2:****92521021****:accesspoint/$apName",
+ "acs:oss:ap-southeast-2:****92521021****:accesspoint/$apName/object/*"
+ ]
+ }]
+}
+BBBB;
+
+ $ossClient->putAccessPointPolicy($alias,$apName,$policy);
+ printf("Put Access Point Success!");
+ } catch (OssException $e) {
+ printf(__FUNCTION__ . ": FAILED\n");
+ printf($e->getMessage() . "\n");
+ return;
+ }
+ print(__FUNCTION__ . ": OK" . "\n");
+}
+
+
+/**
+ * Get Access Point Policy By Alias
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $alias access point alias name
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function getAccessPointPolicyByAlias($ossClient, $alias)
+{
+ try {
+ $apName = "ap-name-01";
+ $result = $ossClient->getAccessPointPolicy($alias,$apName);
+ printf("Get Access Point Policy:%s".PHP_EOL,$result);
+ } catch (OssException $e) {
+ printf(__FUNCTION__ . ": FAILED\n");
+ printf($e->getMessage() . "\n");
+ return;
+ }
+
+ print(__FUNCTION__ . ": OK" . "\n");
+}
+
+/**
+ * Delete Access Point Policy By Alias
+ *
+ * @param OssClient $ossClient OssClient instance
+ * @param string $alias access point alias name
+ * @return null
+ * @throws RequestCore_Exception
+ */
+function deleteAccessPointPolicyByAlias($ossClient, $alias)
+{
+ try{
+ $apName = "ap-name-01";
+ $ossClient->deleteAccessPointPolicy($alias,$apName);
+ printf("Delete Access Point Policy Success!");
+ } catch(OssException $e) {
+ printf($e->getMessage() . "\n");
+ }
+ print(__FUNCTION__ . ": OK" . "\n");
+}
diff --git a/src/OSS/Model/AccessPointConfig.php b/src/OSS/Model/AccessPointConfig.php
new file mode 100644
index 0000000..1fe6e0d
--- /dev/null
+++ b/src/OSS/Model/AccessPointConfig.php
@@ -0,0 +1,90 @@
+accessPointName = $accessPointName;
+ $this->networkOrigin = $networkOrigin;
+ $this->vpcId = $vpcId;
+ }
+
+
+ public function setAccessPointName($accessPointName)
+ {
+ $this->accessPointName = $accessPointName;
+ }
+
+ public function setNetworkOrigin($networkOrigin)
+ {
+ $this->networkOrigin = $networkOrigin;
+ }
+
+ public function setVpcId($vpcId)
+ {
+ $this->vpcId = $vpcId;
+ }
+
+ /**
+ * Parse TaggingConfig from the xml.
+ *
+ * @param string $strXml
+ * @return null
+ */
+ public function parseFromXml($strXml)
+ {
+ }
+
+ /**
+ * Serialize the object into xml string.
+ *
+ * @return string
+ */
+ public function serializeToXml()
+ {
+ $xml = new \SimpleXMLElement('');
+ if (isset($this->accessPointName)){
+ $xml->addChild('AccessPointName',strval($this->accessPointName));
+ }
+ if (isset($this->networkOrigin)){
+ $xml->addChild('NetworkOrigin',strval($this->networkOrigin));
+ }
+ if (isset($this->vpcId)){
+ $xmlVpc = $xml->addChild('VpcConfiguration');
+ $xmlVpc->addChild('VpcId',$this->vpcId);
+ }
+
+ return $xml->asXML();
+ }
+
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->serializeToXml();
+ }
+}
\ No newline at end of file
diff --git a/src/OSS/Model/AccessPointInfo.php b/src/OSS/Model/AccessPointInfo.php
new file mode 100644
index 0000000..744c863
--- /dev/null
+++ b/src/OSS/Model/AccessPointInfo.php
@@ -0,0 +1,121 @@
+accessPointName;
+ }
+
+ public function getBucket(){
+ return $this->bucket;
+ }
+
+ public function getAccountId(){
+ return $this->accountId;
+ }
+
+ public function getNetworkOrigin(){
+ return $this->networkOrigin;
+ }
+
+ public function getVpcId(){
+ return $this->vpcId;
+ }
+
+ public function getAccessPointArn(){
+ return $this->accessPointArn;
+ }
+
+ public function getCreationDate() {
+ return $this->creationDate;
+ }
+
+ public function getAlias(){
+ return $this->alias;
+ }
+
+ public function getStatus(){
+ return $this->status;
+ }
+
+ public function getPublicEndpoint() {
+ return $this->publicEndpoint;
+ }
+
+ public function getInternalEndpoint() {
+ return $this->internalEndpoint;
+ }
+
+ /**
+ * Parse the xml into this object.
+ */
+ public function parseFromXml($strXml)
+ {
+ $xml = simplexml_load_string($strXml);
+ $this->parseFromXmlObj($xml);
+ }
+
+
+ /**
+ * @param $xml \SimpleXMLElement
+ */
+ public function parseFromXmlObj($xml)
+ {
+ if (isset($xml->AccessPointName)){
+ $this->accessPointName = strval($xml->AccessPointName);
+ }
+ if (isset($xml->Bucket)){
+ $this->bucket = strval($xml->Bucket);
+ }
+ if (isset($xml->AccountId)){
+ $this->accountId = strval($xml->AccountId);
+ }
+ if (isset($xml->NetworkOrigin)){
+ $this->networkOrigin = strval($xml->NetworkOrigin);
+ }
+ if (isset($xml->VpcConfiguration->VpcId)){
+ $this->vpcId = strval($xml->VpcConfiguration->VpcId);
+ }
+ if (isset($xml->AccessPointArn)){
+ $this->accessPointArn = strval($xml->AccessPointArn);
+ }
+ if (isset($xml->CreationDate)){
+ $this->creationDate = strval($xml->CreationDate);
+ }
+ if (isset($xml->CreationDate)){
+ $this->creationDate = strval($xml->CreationDate);
+ }
+ if (isset($xml->Alias)){
+ $this->alias = strval($xml->Alias);
+ }
+ if (isset($xml->Status)){
+ $this->status = strval($xml->Status);
+ }
+
+ if (isset($xml->Endpoints->PublicEndpoint)){
+ $this->publicEndpoint = strval($xml->Endpoints->PublicEndpoint);
+ }
+
+ if (isset($xml->Endpoints->InternalEndpoint)){
+ $this->internalEndpoint = strval($xml->Endpoints->InternalEndpoint);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/OSS/Model/ListAccessPoints.php b/src/OSS/Model/ListAccessPoints.php
new file mode 100644
index 0000000..3c6176a
--- /dev/null
+++ b/src/OSS/Model/ListAccessPoints.php
@@ -0,0 +1,80 @@
+isTruncated;
+ }
+
+ public function getNextContinuationToken(){
+ return $this->nextContinuationToken;
+ }
+
+ public function getAccountId(){
+ return $this->accountId;
+ }
+
+ public function getAccessPoints(){
+ return $this->accessPoints;
+ }
+
+ /**
+ * Parse the xml into this object.
+ */
+ public function parseFromXml($strXml)
+ {
+ $xml = simplexml_load_string($strXml);
+ if (!isset($xml->IsTruncated) && !isset($xml->NextContinuationToken) && !isset($xml->AccountId) && !isset($xml->MaxKeys) && !isset($xml->AccessPoints)) return;
+ if (isset($xml->IsTruncated)){
+ $this->isTruncated = strval($xml->IsTruncated) === 'TRUE' || strval($xml->IsTruncated) === 'true';
+ }
+ if (isset($xml->NextContinuationToken)){
+ $this->nextContinuationToken = strval($xml->NextContinuationToken);
+ }
+ if (isset($xml->AccountId)){
+ $this->accountId = strval($xml->AccountId);
+ }
+ if (isset($xml->AccessPoints)){
+ $this->parseAccessPoints($xml->AccessPoints);
+ }
+ }
+
+ /**
+ * @param $xmlAccessPoints \SimpleXMLElement
+ */
+ private function parseAccessPoints($xmlAccessPoints){
+ if ($xmlAccessPoints){
+ foreach ($xmlAccessPoints->AccessPoint as $accessPoint){
+ $access = new AccessPointInfo();
+ $access->parseFromXmlObj($accessPoint);
+ $this->accessPoints[] = $access;
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/OSS/OssClient.php b/src/OSS/OssClient.php
index c953344..2060bfd 100644
--- a/src/OSS/OssClient.php
+++ b/src/OSS/OssClient.php
@@ -9,8 +9,11 @@
use OSS\Http\RequestCore;
use OSS\Http\RequestCore_Exception;
use OSS\Http\ResponseCore;
+use OSS\Model\AccessPointConfig;
+use OSS\Model\AccessPointInfo;
use OSS\Model\CorsConfig;
use OSS\Model\CnameConfig;
+use OSS\Model\ListAccessPoints;
use OSS\Model\LoggingConfig;
use OSS\Model\LiveChannelConfig;
use OSS\Model\LiveChannelInfo;
@@ -19,6 +22,7 @@
use OSS\Model\StorageCapacityConfig;
use OSS\Result\AclResult;
use OSS\Result\BodyResult;
+use OSS\Result\GetBucketAccessPointResult;
use OSS\Result\GetCorsResult;
use OSS\Result\GetLifecycleResult;
use OSS\Result\GetLocationResult;
@@ -29,6 +33,7 @@
use OSS\Result\GetCnameResult;
use OSS\Result\HeaderResult;
use OSS\Result\InitiateMultipartUploadResult;
+use OSS\Result\ListBucketAccessPointResult;
use OSS\Result\ListBucketsResult;
use OSS\Result\ListMultipartUploadResult;
use OSS\Model\ListMultipartUploadInfo;
@@ -1633,6 +1638,167 @@ public function getBucketTransferAcceleration($bucket,$options = NULL)
return $result->getData();
}
+ /**
+ * Put Bucket Access Point
+ * @param string $bucket bucket name
+ * @param AccessPointConfig $config config
+ * @param null $options
+ * @return AccessPointInfo|null
+ * @throws OssException|RequestCore_Exception
+ */
+ public function putBucketAccessPoint($bucket,$config,$options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'accessPoint';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $options[self::OSS_CONTENT] = $config->serializeToXml();
+ $response = $this->auth($options);
+ $result = new GetBucketAccessPointResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Get Bucket Access Point
+ * @param string $bucket bucket name
+ * @param string $apName ap name
+ * @param null $options
+ * @return AccessPointInfo|null
+ * @throws OssException|RequestCore_Exception
+ */
+ public function getBucketAccessPoint($bucket,$apName,$options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'accessPoint';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $options[self::OSS_HEADERS][self::OSS_ACCESS_POINT_NAME] = $apName;
+ $response = $this->auth($options);
+ $result = new GetBucketAccessPointResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * List Bucket Access Point
+ * @param string $bucket bucket name
+ * @param array|null $options
+ * @return ListAccessPoints|null
+ * @throws OssException|RequestCore_Exception
+ */
+ public function listBucketAccessPoint($bucket,$options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'accessPoint';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ if (isset($options[self::OSS_MAX_KEYS])){
+ $options[self::OSS_QUERY_STRING][self::OSS_MAX_KEYS] = $options[self::OSS_MAX_KEYS];
+ }
+ if(isset($options[self::OSS_CONTINUATION_TOKEN])){
+ $options[self::OSS_QUERY_STRING][self::OSS_CONTINUATION_TOKEN] = $options[self::OSS_CONTINUATION_TOKEN];
+ }
+ $response = $this->auth($options);
+ $result = new ListBucketAccessPointResult($response);
+ return $result->getData();
+ }
+
+
+ /**
+ * Delete Bucket Access Point
+ * @param string $bucket bucket name
+ * @param string $apName access point name
+ * @param array|null $options
+ * @return ListAccessPoints|null
+ * @throws OssException|RequestCore_Exception
+ */
+ public function deleteBucketAccessPoint($bucket,$apName,$options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'accessPoint';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $options[self::OSS_HEADERS][self::OSS_ACCESS_POINT_NAME] = $apName;
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Put Access Point Policy
+ * @param string $bucket bucket name
+ * @param string $apName access name
+ * @param string $policy policy in json format
+ * @param array|null $options
+ * @return AccessPointInfo|null
+ * @throws OssException|RequestCore_Exception
+ */
+ public function putAccessPointPolicy($bucket,$apName,$policy,$options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'accessPointPolicy';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $options[self::OSS_HEADERS][self::OSS_ACCESS_POINT_NAME] = $apName;
+ $options[self::OSS_CONTENT] = $policy;
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Get Access Point Policy
+ * @param string $bucket bucket name
+ * @param string $apName ap name
+ * @param null $options
+ * @return BodyResult|null
+ * @throws OssException|RequestCore_Exception
+ */
+ public function getAccessPointPolicy($bucket,$apName,$options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'accessPointPolicy';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $options[self::OSS_HEADERS][self::OSS_ACCESS_POINT_NAME] = $apName;
+ $response = $this->auth($options);
+ $result = new BodyResult($response);
+ return $result->getData();
+ }
+
+
+ /**
+ * Delete Access Point Policy
+ * @param string $bucket bucket name
+ * @param string $apName ap name
+ * @param null $options
+ * @return AccessPointInfo|null
+ * @throws OssException|RequestCore_Exception
+ */
+ public function deleteAccessPointPolicy($bucket,$apName,$options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'accessPointPolicy';
+ $options[self::OSS_HEADERS][self::OSS_ACCESS_POINT_NAME] = $apName;
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
/**
* Lists the bucket's object list (in ObjectListInfo)
*
@@ -3678,6 +3844,7 @@ public function setConnectTimeout($connectTimeout)
const OSS_VERSION_ID = 'versionId';
const OSS_HEADER_VERSION_ID = 'x-oss-version-id';
const OSS_CNAME = 'cname';
+ const OSS_ACCESS_POINT_NAME = 'x-oss-access-point-name';
//private URLs
const OSS_URL_ACCESS_KEY_ID = 'OSSAccessKeyId';
diff --git a/src/OSS/Result/GetBucketAccessPointResult.php b/src/OSS/Result/GetBucketAccessPointResult.php
new file mode 100644
index 0000000..f778747
--- /dev/null
+++ b/src/OSS/Result/GetBucketAccessPointResult.php
@@ -0,0 +1,24 @@
+rawResponse->body;
+ $info = new AccessPointInfo();
+ $info->parseFromXml($content);
+ return $info;
+ }
+}
\ No newline at end of file
diff --git a/src/OSS/Result/ListBucketAccessPointResult.php b/src/OSS/Result/ListBucketAccessPointResult.php
new file mode 100644
index 0000000..eedad38
--- /dev/null
+++ b/src/OSS/Result/ListBucketAccessPointResult.php
@@ -0,0 +1,23 @@
+rawResponse->body;
+ $info = new ListAccessPoints();
+ $info->parseFromXml($content);
+ return $info;
+ }
+}
\ No newline at end of file
diff --git a/tests/OSS/Tests/AccessPointConfigTest.php b/tests/OSS/Tests/AccessPointConfigTest.php
new file mode 100644
index 0000000..896b9cd
--- /dev/null
+++ b/tests/OSS/Tests/AccessPointConfigTest.php
@@ -0,0 +1,60 @@
+
+
+ap-01
+vpc
+
+vpc-t4nlw426y44rd3iq4****
+
+
+BBBB;
+ private $validXml1 = <<
+
+ap-01
+internet
+
+BBBB;
+
+ private $invalidXml = <<
+
+BBBB;
+
+ public function testParseValidXml()
+ {
+ $apName = "ap-01";
+ $net = "vpc";
+ $vpcId = "vpc-t4nlw426y44rd3iq4****";
+ $accessConfig = new AccessPointConfig($apName,$net,$vpcId);
+ $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml(strval($accessConfig)));
+ }
+
+ public function testValidXml1()
+ {
+ $apName = "ap-01";
+ $net = "internet";
+ $accessConfig = new AccessPointConfig($apName,$net);
+ $this->assertEquals($this->cleanXml($this->validXml1), $this->cleanXml(strval($accessConfig)));
+ }
+
+ public function testInvalidXml1()
+ {
+ $accessConfig = new AccessPointConfig();
+ $this->assertEquals($this->cleanXml($this->invalidXml), $this->cleanXml(strval($accessConfig)));
+ }
+
+ private function cleanXml($xml)
+ {
+ return str_replace("\n", "", str_replace("\r", "", $xml));
+ }
+}
diff --git a/tests/OSS/Tests/GetBucketAccessPointResultTest.php b/tests/OSS/Tests/GetBucketAccessPointResultTest.php
new file mode 100644
index 0000000..97c376a
--- /dev/null
+++ b/tests/OSS/Tests/GetBucketAccessPointResultTest.php
@@ -0,0 +1,117 @@
+
+
+ap-01
+oss-example
+111933544165****
+vpc
+
+vpc-t4nlw426y44rd3iq4****
+
+arn:acs:oss:ap-southeast-2:111933544165****:accesspoint/ap-01
+1626769503
+ap-01-ossalias
+enable
+
+ap-01.oss-ap-southeast-2.oss-accesspoint.aliyuncs.com
+ap-01.oss-ap-southeast-2-internal.oss-accesspoint.aliyuncs.com
+
+
+BBBB;
+
+ private $validXml1 = <<
+
+ap-01
+oss-example
+111933544165****
+internet
+
+
+
+arn:acs:oss:ap-southeast-2:111933544165****:accesspoint/ap-01
+1626769503
+ap-01-ossalias
+enable
+
+ap-01.oss-ap-southeast-2.oss-accesspoint.aliyuncs.com
+ap-01.oss-ap-southeast-2-internal.oss-accesspoint.aliyuncs.com
+
+
+BBBB;
+
+ private $nullXml = <<
+
+BBBB;
+ public function testParseValidXml()
+ {
+ $response = new ResponseCore(array(), $this->validXml, 200);
+ $result = new GetBucketAccessPointResult($response);
+ $this->assertTrue($result->isOK());
+ $this->assertNotNull($result->getData());
+ $this->assertNotNull($result->getRawResponse());
+ $config = $result->getData();
+ $this->assertEquals("ap-01", $config->getAccessPointName());
+ $this->assertEquals("oss-example", $config->getBucket());
+ $this->assertEquals("111933544165****", $config->getAccountId());
+ $this->assertEquals("vpc", $config->getNetworkOrigin());
+ $this->assertEquals("vpc-t4nlw426y44rd3iq4****", $config->getVpcId());
+ $this->assertEquals("arn:acs:oss:ap-southeast-2:111933544165****:accesspoint/ap-01", $config->getAccessPointArn());
+ $this->assertEquals("1626769503", $config->getCreationDate());
+ $this->assertEquals("ap-01-ossalias", $config->getAlias());
+ $this->assertEquals("enable", $config->getStatus());
+ $this->assertEquals("ap-01.oss-ap-southeast-2.oss-accesspoint.aliyuncs.com", $config->getPublicEndpoint());
+ $this->assertEquals("ap-01.oss-ap-southeast-2-internal.oss-accesspoint.aliyuncs.com", $config->getInternalEndpoint());
+ }
+
+ public function testParseValidXml1()
+ {
+ $response = new ResponseCore(array(), $this->validXml1, 200);
+ $result = new GetBucketAccessPointResult($response);
+ $this->assertTrue($result->isOK());
+ $this->assertNotNull($result->getData());
+ $this->assertNotNull($result->getRawResponse());
+ $config = $result->getData();
+ $this->assertEquals("ap-01", $config->getAccessPointName());
+ $this->assertEquals("oss-example", $config->getBucket());
+ $this->assertEquals("111933544165****", $config->getAccountId());
+ $this->assertEquals("internet", $config->getNetworkOrigin());
+ $this->assertEquals(null, $config->getVpcId());
+ $this->assertEquals("arn:acs:oss:ap-southeast-2:111933544165****:accesspoint/ap-01", $config->getAccessPointArn());
+ $this->assertEquals("1626769503", $config->getCreationDate());
+ $this->assertEquals("ap-01-ossalias", $config->getAlias());
+ $this->assertEquals("enable", $config->getStatus());
+ $this->assertEquals("ap-01.oss-ap-southeast-2.oss-accesspoint.aliyuncs.com", $config->getPublicEndpoint());
+ $this->assertEquals("ap-01.oss-ap-southeast-2-internal.oss-accesspoint.aliyuncs.com", $config->getInternalEndpoint());
+ }
+
+ public function testParseNullXml()
+ {
+ $response = new ResponseCore(array(), $this->nullXml, 200);
+ $result = new GetBucketAccessPointResult($response);
+ $config = $result->getData();
+ $this->assertEquals(null, $config->getAccessPointName());
+ $this->assertEquals(null, $config->getBucket());
+ $this->assertEquals(null, $config->getAccountId());
+ $this->assertEquals(null, $config->getNetworkOrigin());
+ $this->assertEquals(null, $config->getVpcId());
+ $this->assertEquals(null, $config->getAccessPointArn());
+ $this->assertEquals(null, $config->getCreationDate());
+ $this->assertEquals(null, $config->getAlias());
+ $this->assertEquals(null, $config->getStatus());
+ $this->assertEquals(null, $config->getPublicEndpoint());
+ $this->assertEquals(null, $config->getInternalEndpoint());
+
+ }
+}
diff --git a/tests/OSS/Tests/ListBucketAccessPointResultTest.php b/tests/OSS/Tests/ListBucketAccessPointResultTest.php
new file mode 100644
index 0000000..e6b4444
--- /dev/null
+++ b/tests/OSS/Tests/ListBucketAccessPointResultTest.php
@@ -0,0 +1,83 @@
+
+
+true
+abc
+111933544165****
+
+
+oss-example
+ap-01
+ap-01-ossalias
+vpc
+
+vpc-t4nlw426y44rd3iq4****
+
+enable
+
+
+ap-02
+access-point-name-2-1280*****-ossalias
+oss-example
+internet
+
+enable
+
+
+
+BBBB;
+
+ private $nullXml = <<
+
+BBBB;
+ public function testParseValidXml()
+ {
+ $response = new ResponseCore(array(), $this->validXml, 200);
+ $result = new ListBucketAccessPointResult($response);
+ $this->assertTrue($result->isOK());
+ $this->assertNotNull($result->getData());
+ $this->assertNotNull($result->getRawResponse());
+ $list = $result->getData();
+ $this->assertEquals(true, $list->getIsTruncated());
+ $this->assertEquals("111933544165****", $list->getAccountId());
+ $this->assertEquals("abc", $list->getNextContinuationToken());
+ $accessPoints = $list->getAccessPoints();
+ $this->assertEquals(2, count($accessPoints));
+ $this->assertEquals("ap-01", $accessPoints[0]->getAccessPointName());
+ $this->assertEquals("oss-example", $accessPoints[0]->getBucket());
+ $this->assertEquals("ap-01-ossalias", $accessPoints[0]->getAlias());
+ $this->assertEquals("vpc-t4nlw426y44rd3iq4****", $accessPoints[0]->getVpcId());
+ $this->assertEquals("vpc", $accessPoints[0]->getNetworkOrigin());
+ $this->assertEquals("enable", $accessPoints[0]->getStatus());
+
+ $this->assertEquals("ap-02", $accessPoints[1]->getAccessPointName());
+ $this->assertEquals("oss-example", $accessPoints[1]->getBucket());
+ $this->assertEquals("access-point-name-2-1280*****-ossalias", $accessPoints[1]->getAlias());
+ $this->assertEquals(null, $accessPoints[1]->getVpcId());
+ $this->assertEquals("internet", $accessPoints[1]->getNetworkOrigin());
+ $this->assertEquals("enable", $accessPoints[1]->getStatus());
+ }
+
+ public function testParseNullXml()
+ {
+ $response = new ResponseCore(array(), $this->nullXml, 200);
+ $result = new ListBucketAccessPointResult($response);
+ $list = $result->getData();
+ $this->assertEquals(null, $list->getIsTruncated());
+ $this->assertEquals(null, $list->getAccountId());
+ $this->assertEquals(null, $list->getNextContinuationToken());
+ $accessPoints = $list->getAccessPoints();
+ $this->assertEquals(null, $accessPoints);
+
+ }
+}
diff --git a/tests/OSS/Tests/OssClientBucketAccessPointTest.php b/tests/OSS/Tests/OssClientBucketAccessPointTest.php
new file mode 100644
index 0000000..e933e24
--- /dev/null
+++ b/tests/OSS/Tests/OssClientBucketAccessPointTest.php
@@ -0,0 +1,234 @@
+fail("account id is empty!");
+ }
+
+ try {
+ $apName = 'ap1-'.time();
+ $net = "vpc";
+ $vpcId = "vpc-123456789";
+ $accessConfig = new AccessPointConfig($apName,$net,$vpcId);
+ $result = $this->ossClient->putBucketAccessPoint($this->bucket,$accessConfig);
+ $this->assertNotNull($result->getAccessPointArn());
+ $this->assertNotNull($result->getAlias());
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+
+ Common::waitMetaSync();
+ try {
+ $res = $this->ossClient->getBucketAccessPoint($this->bucket,$apName);
+ $this->assertEquals($res->getAccessPointName(),$apName);
+ $this->assertEquals($res->getBucket(),$this->bucket);
+ $this->assertNotNull($res->getAccountId());
+ $this->assertEquals($res->getNetworkOrigin(),$net);
+ $this->assertEquals($res->getVpcId(),$vpcId);
+ $this->assertNotNull($res->getAccessPointArn());
+ $this->assertNotNull($res->getStatus());
+ $this->assertNotNull($res->getCreationDate());
+ $this->assertNotNull($res->getAlias());
+ $this->assertNotNull($res->getInternalEndpoint());
+ $this->assertNotNull($res->getPublicEndpoint());
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+
+ try {
+ $apName2 = 'ap2-'.time();
+ $net2 = "internet";
+ $accessConfig = new AccessPointConfig($apName2,$net2);
+ $result = $this->ossClient->putBucketAccessPoint($this->bucket,$accessConfig);
+ $this->assertNotNull($result->getAccessPointArn());
+ $this->assertNotNull($result->getAlias());
+ $alias = $result->getAlias();
+ $accessPointArn = $result->getAccessPointArn();
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+ Common::waitMetaSync();
+ try {
+ $list = $this->ossClient->listBucketAccessPoint($this->bucket);
+ $this->assertNotNull($list->getAccountId());
+ $this->assertNull($list->getNextContinuationToken());
+ $this->assertEquals($list->getIsTruncated(),false);
+ $accessPoints = $list->getAccessPoints();
+ $this->assertEquals(2, count($accessPoints));
+ $this->assertEquals($apName, $accessPoints[0]->getAccessPointName());
+ $this->assertEquals($this->bucket, $accessPoints[0]->getBucket());
+ $this->assertNotNull($accessPoints[0]->getAlias());
+ $this->assertEquals("vpc-123456789", $accessPoints[0]->getVpcId());
+ $this->assertEquals("vpc", $accessPoints[0]->getNetworkOrigin());
+ $this->assertNotNull($accessPoints[0]->getStatus());
+
+ $this->assertEquals($apName2, $accessPoints[1]->getAccessPointName());
+ $this->assertEquals($this->bucket, $accessPoints[1]->getBucket());
+ $this->assertNotNull($accessPoints[1]->getAlias());
+ $this->assertEquals(null, $accessPoints[1]->getVpcId());
+ $this->assertEquals("internet", $accessPoints[1]->getNetworkOrigin());
+ $this->assertNotNull($accessPoints[1]->getStatus());
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+
+ while (true){
+ $res = $this->ossClient->getBucketAccessPoint($this->bucket,$apName);
+ if ($res->getStatus() == 'enable'){
+ break;
+ }
+ sleep(20);
+ }
+ $policy = <<ossClient->putAccessPointPolicy($this->bucket,$apName2,$policy);
+ $this->assertTrue(true);
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+ Common::waitMetaSync();
+
+ try {
+ $info = $this->ossClient->getAccessPointPolicy($this->bucket,$apName2);
+ $this->assertNotNull($info);
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+ $policy2 = <<ossClient->getBucketAccessPoint($this->bucket,$apName2);
+ if ($res->getStatus() == 'enable'){
+ break;
+ }
+ sleep(20);
+ }
+ try {
+ $this->ossClient->putAccessPointPolicy($alias,$apName2,$policy2);
+ $this->assertTrue(true);
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+ Common::waitMetaSync();
+
+ try {
+ $this->ossClient->getAccessPointPolicy($alias,$apName2);
+ $this->assertTrue(true);
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+
+ try {
+ $this->ossClient->deleteAccessPointPolicy($alias,$apName2);
+ $this->assertTrue(true);
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+
+ try {
+ $this->ossClient->putAccessPointPolicy($this->bucket,$apName2,$policy2);
+ $this->assertTrue(true);
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+ Common::waitMetaSync();
+
+ try {
+ $this->ossClient->deleteAccessPointPolicy($this->bucket,$apName);
+ $this->assertTrue(true);
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+
+
+ while (true){
+ try {
+ $list = $this->ossClient->listBucketAccessPoint($this->bucket);
+ $accessPoints = $list->getAccessPoints();
+ if (isset($accessPoints) && count($accessPoints) > 0){
+ foreach ($accessPoints as $accessPoint){
+ if ($accessPoint->getStatus() == "enable"){
+ $this->ossClient->deleteBucketAccessPoint($this->bucket,$accessPoint->getAccessPointName());
+ }
+ }
+ }else{
+ break;
+ }
+ sleep(30);
+ }catch (OssException $e){
+ printf($e->getMessage());
+ $this->assertTrue(false);
+ }
+
+ }
+ }
+}
diff --git a/tests/OSS/Tests/PutBucketAccessPointResultTest.php b/tests/OSS/Tests/PutBucketAccessPointResultTest.php
new file mode 100644
index 0000000..891b433
--- /dev/null
+++ b/tests/OSS/Tests/PutBucketAccessPointResultTest.php
@@ -0,0 +1,45 @@
+
+
+acs:oss:ap-southeast-2:128364106451****:accesspoint/ap-01
+ap-01-45ee7945007a2f0bcb595f63e2215c****-ossalias
+
+BBBB;
+
+ private $invalidXml = <<
+
+
+BBBB;
+ public function testParseValidXml()
+ {
+ $response = new ResponseCore(array(), $this->validXml, 200);
+ $result = new GetBucketAccessPointResult($response);
+ $this->assertTrue($result->isOK());
+ $this->assertNotNull($result->getData());
+ $this->assertNotNull($result->getRawResponse());
+ $config = $result->getData();
+ $this->assertEquals("acs:oss:ap-southeast-2:128364106451****:accesspoint/ap-01", $config->getAccessPointArn());
+ $this->assertEquals("ap-01-45ee7945007a2f0bcb595f63e2215c****-ossalias", $config->getAlias());
+ }
+
+ public function testParseNullXml()
+ {
+ $response = new ResponseCore(array(), $this->invalidXml, 200);
+ $result = new GetBucketAccessPointResult($response);
+ $config = $result->getData();
+ $this->assertEquals(null, $config->getAccessPointArn());
+ $this->assertEquals(null, $config->getAlias());
+
+ }
+}