diff --git a/src/InfluxDB/Adapter/AdapterInterface.php b/src/InfluxDB/Adapter/AdapterInterface.php index 73d1b2fe58..b4ac32821f 100644 --- a/src/InfluxDB/Adapter/AdapterInterface.php +++ b/src/InfluxDB/Adapter/AdapterInterface.php @@ -11,5 +11,5 @@ interface AdapterInterface * @param mixed $message * @param string|boolean $timePrecision */ - public function send($message, $timePrecision = false); + public function send($message); } diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 2ebbceed1d..fdd0d16808 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -78,47 +78,6 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface return $this->get($options); } - /** - * {@inheritDoc} - */ - public function getDatabases() - { - $options = [ - "auth" => [$this->options->getUsername(), $this->options->getPassword()], - "query" => [ - "q" => "show databases", - ], - ]; - - return $this->get($options); - } - - /** - * {@inheritDoc} - */ - public function createDatabase($name) - { - $httpMessage = [ - "auth" => [$this->options->getUsername(), $this->options->getPassword()], - "query" => ["q" => "CREATE DATABASE \"{$name}\""], - ]; - - return $this->get($httpMessage); - } - - /** - * {@inheritDoc} - */ - public function deleteDatabase($name) - { - $httpMessage = [ - "auth" => [$this->options->getUsername(), $this->options->getPassword()], - "query" => ["q" => "drop database \"{$name}\""], - ]; - - return $this->get($httpMessage); - } - private function get(array $httpMessage) { $endpoint = $this->options->getHttpQueryEndpoint(); diff --git a/src/InfluxDB/Adapter/QueryableInterface.php b/src/InfluxDB/Adapter/QueryableInterface.php index 3bed923849..9ce4440dc3 100644 --- a/src/InfluxDB/Adapter/QueryableInterface.php +++ b/src/InfluxDB/Adapter/QueryableInterface.php @@ -1,34 +1,7 @@ adapter; } - public function mark($name, array $values = [], $timePrecision = false) + public function mark($name, array $values = []) { $data = $name; if (!is_array($name)) { $data =[]; - $timePrecision = $this->clearTimePrecision($timePrecision); - $data["database"] = $this->getAdapter()->getOptions()->getDatabase(); $data['points'][0]['name'] = $name; $data['points'][0]['fields'] = $values; } - return $this->getAdapter()->send($data, $timePrecision); + return $this->getAdapter()->send($data); } - public function query($query, $timePrecision = false) + public function query($query) { if (!($this->getAdapter() instanceOf QueryableInterface)) { throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); } - $timePrecision = $this->clearTimePrecision($timePrecision); - - $return = $this->getAdapter()->query($query, $timePrecision); + $return = $this->getAdapter()->query($query); return $return; } @@ -57,7 +53,7 @@ class Client if (!($this->getAdapter() instanceOf QueryableInterface)) { throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); } - return $this->getAdapter()->getDatabases(); + return $this->getAdapter()->query("show databases"); } public function createDatabase($name) @@ -65,7 +61,7 @@ class Client if (!($this->getAdapter() instanceOf QueryableInterface)) { throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); } - return $this->getAdapter()->createDatabase($name); + return $this->getAdapter()->query("create database \"{$name}\""); } public function deleteDatabase($name) @@ -73,7 +69,7 @@ class Client if (!($this->getAdapter() instanceOf QueryableInterface)) { throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); } - return $this->getAdapter()->deleteDatabase($name); + return $this->getAdapter()->query("drop database \"{$name}\""); } private function clearTimePrecision($timePrecision) diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index c569c420a6..5a498452ab 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -97,41 +97,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } - /** - * @group tcp - */ - public function testGuzzleHttpQueryApiWithTimePrecision() - { - $this->markTestSkipped("Skip time precision"); - $this->object->mark("tcp.test", ["mark" => "element"]); - - sleep(1); - - $body = $this->object->query("select mark from \"tcp.test\"", "s"); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); - } - - /** - * @group tcp - */ - public function testGuzzleHttpWriteApiWithTimePrecision() - { - $this->markTestSkipped("Skip time precision"); - $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); - - sleep(1); - - $body = $this->object->query("select mark from \"tcp.test\"", "ms"); - - $this->assertCount(1, $body[0]["points"]); - $this->assertEquals("tcp.test", $body[0]["name"]); - - $this->assertEquals("1410591552000", $body[0]["points"][0][0]); - } - /** * @group udp */