From 65dc8a4d7d22f8ef5cfe709cec7dcdd0ba320007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E4=B8=8B?= Date: Tue, 18 Jun 2019 10:05:37 +0800 Subject: [PATCH] add reserved capacity list interface --- src/AliyunFC/Client.php | 16 ++++++++++++++++ test/client_test.php | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/AliyunFC/Client.php b/src/AliyunFC/Client.php index 43aaeeb..9663855 100644 --- a/src/AliyunFC/Client.php +++ b/src/AliyunFC/Client.php @@ -820,4 +820,20 @@ public function getResourceTags($options, $headers=[]){ $headers = $this->buildCommonHeaders($method, $path, $headers); return $this->doRequest($method, $path, $headers, $data = null, $query = $options); } + + public function listReservedCapacities($options = [], $headers = []) { + /* + @param options: optional + @param headers, optional + 1, 'x-fc-trace-id': string (a uuid to do the request tracing) + 2, 'if-match': string + 3, user define key value + @return: array + */ + $method = 'GET'; + $path = sprintf('/%s/reservedCapacities', $this->apiVersion); + $headers = $this->buildCommonHeaders($method, $path, $headers); + + return $this->doRequest($method, $path, $headers, $data = null, $query = $options); + } } \ No newline at end of file diff --git a/test/client_test.php b/test/client_test.php index 8600521..92e9408 100644 --- a/test/client_test.php +++ b/test/client_test.php @@ -836,6 +836,21 @@ private function subTestHttpTrigger($serviceName, $functionName) { $this->fcClient->deleteTrigger($serviceName, $functionName, $triggerName); } + public function testListReservedCapacities() { + $r = $this->fcClient->listReservedCapacities(["limit" => 5]); + $r = $r['data']; + $rcs = $r['reservedCapacities']; + $this->assertLessThanOrEqual(5, count($rcs)); + + for ($i=0; $iassertEquals(strlen($rcs[i]['instanceId']), 22); + $this->assertGreaterThan(0, $rcs[i]['cu']); + $this->assertGreaterThan($rcs[i]['createdTime'], $rcs[i]['deadline']); + $this->assertNotNull($rcs[i]['lastModifiedTime']); + $this->assertNotNull($rcs[i]['isRefunded']); + } + } + public function testException() { $err = ''; try {