Changeset View
Changeset View
Standalone View
Standalone View
src/future/aws/PhutilAWSFuture.php
<?php | <?php | ||||
abstract class PhutilAWSFuture extends FutureProxy { | abstract class PhutilAWSFuture extends FutureProxy { | ||||
private $future; | private $future; | ||||
private $accessKey; | private $accessKey; | ||||
private $secretKey; | private $secretKey; | ||||
private $region; | private $region; | ||||
private $httpMethod = 'GET'; | private $httpMethod = 'GET'; | ||||
private $path = '/'; | private $path = '/'; | ||||
private $params = array(); | private $params = array(); | ||||
private $endpoint; | private $endpoint; | ||||
private $data = ''; | |||||
private $headers = array(); | |||||
abstract public function getServiceName(); | abstract public function getServiceName(); | ||||
public function __construct() { | public function __construct() { | ||||
parent::__construct(null); | parent::__construct(null); | ||||
} | } | ||||
public function setAccessKey($access_key) { | public function setAccessKey($access_key) { | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | public function setPath($path) { | ||||
$this->path = $path; | $this->path = $path; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPath() { | public function getPath() { | ||||
return $this->path; | return $this->path; | ||||
} | } | ||||
public function setData($data) { | |||||
$this->data = $data; | |||||
return $this; | |||||
} | |||||
public function getData() { | |||||
return $this->data; | |||||
} | |||||
protected function getParameters() { | protected function getParameters() { | ||||
$params = $this->params; | $params = $this->params; | ||||
return $params; | return $params; | ||||
} | } | ||||
public function addHeader($key, $value) { | |||||
$this->headers[] = array($key, $value); | |||||
return $this; | |||||
} | |||||
protected function getProxiedFuture() { | protected function getProxiedFuture() { | ||||
if (!$this->future) { | if (!$this->future) { | ||||
$params = $this->getParameters(); | $params = $this->getParameters(); | ||||
$method = $this->getHTTPMethod(); | $method = $this->getHTTPMethod(); | ||||
$host = $this->getEndpoint(); | $host = $this->getEndpoint(); | ||||
$path = $this->getPath(); | $path = $this->getPath(); | ||||
$data = $this->getData(); | |||||
$uri = id(new PhutilURI("https://{$host}/")) | $uri = id(new PhutilURI("https://{$host}/")) | ||||
->setPath($path) | ->setPath($path) | ||||
->setQueryParams($params); | ->setQueryParams($params); | ||||
$future = id(new HTTPSFuture($uri)) | $future = id(new HTTPSFuture($uri, $data)) | ||||
->setMethod($method); | ->setMethod($method); | ||||
foreach ($this->headers as $header) { | |||||
list($key, $value) = $header; | |||||
$future->addHeader($key, $value); | |||||
} | |||||
$this->signRequest($future); | $this->signRequest($future); | ||||
$this->future = $future; | $this->future = $future; | ||||
} | } | ||||
return $this->future; | return $this->future; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |