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 access point api #268

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
408 changes: 408 additions & 0 deletions samples/BucketAccessPoint.php

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions src/OSS/Model/AccessPointConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

namespace OSS\Model;


use OSS\Core\OssException;

/**
* Class AccessPointConfig
* @package OSS\Model
*
*/
class AccessPointConfig implements XmlConfig
{
const VPC = 'vpc';
const INTERNET = 'internet';
private $accessPointName;
private $networkOrigin;
private $vpcId;

/**
* AccessPointConfig constructor.
* @param string|null $accessPointName
* @param string|null $networkOrigin
* @param string|null $vpcId
*/
public function __construct($accessPointName=null,$networkOrigin=null,$vpcId=null)
{
$this->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('<?xml version="1.0" encoding="utf-8"?><CreateAccessPointConfiguration></CreateAccessPointConfiguration>');
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();
}
}
121 changes: 121 additions & 0 deletions src/OSS/Model/AccessPointInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php
namespace OSS\Model;

/**
* Class AccessPointInfo
* @package OSS\Model
*
*/
class AccessPointInfo{

private $accessPointName;
private $bucket;
private $accountId;
private $networkOrigin;
private $vpcId;
private $accessPointArn;
private $creationDate;
private $alias;
private $status;
private $publicEndpoint;
private $internalEndpoint;

public function getAccessPointName(){
return $this->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);
}
}
}
80 changes: 80 additions & 0 deletions src/OSS/Model/ListAccessPoints.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace OSS\Model;

/**
* Class ListAccessPoints
* @package OSS\Model
*
*/
class ListAccessPoints{

/**
* @var string
*/
private $isTruncated;
/**
* @var string
*/
private $nextContinuationToken;

/**
* @var AccessPointInfo[]
*/
private $accessPoints;

private $accountId;

private $maxKeys;

public function getIsTruncated(){
return $this->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;
}
}
}

}
Loading