From f9c4bdb7a17e10de689fb44be82130811cdae3cf Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Mon, 27 Apr 2015 11:02:13 -0400 Subject: [PATCH 01/16] added method for getQPS to zone, and a check forthe msgs parameter in response (qps does not have this property) --- src/TrafficManagement/Api/Response.php | 4 +++- src/TrafficManagement/Zone.php | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/TrafficManagement/Api/Response.php b/src/TrafficManagement/Api/Response.php index 880948c..38dc99e 100644 --- a/src/TrafficManagement/Api/Response.php +++ b/src/TrafficManagement/Api/Response.php @@ -37,7 +37,9 @@ public static function fromJson($json) $response = new Response(); $response->job_id = $json->job_id; $response->status = $json->status; - $response->msgs = $json->msgs; + if ($response->msgs){ + $response->msgs = $json->msgs; + } $response->data = $json->data; return $response; diff --git a/src/TrafficManagement/Zone.php b/src/TrafficManagement/Zone.php index b22a365..52eb090 100644 --- a/src/TrafficManagement/Zone.php +++ b/src/TrafficManagement/Zone.php @@ -88,6 +88,24 @@ public function getName() return $this->name; } + + /** + * + * API request for this zones QPS reports for the given timeframe + * + * @param $start int + * @param $end int + * @return ApiResponse|false + */ + public function getQPS($start, $end) + { + $path = '/QPSReport/'; + + $result = $this->apiClient->post($path, ['start_ts'=>$start,'end_ts'=>$end,'zones'=>[$this->name]]); + + return $result; + } + /** * Setter for type * From 883b45d2e5271219d49ed30277fa74d2b1bf7623 Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Tue, 26 May 2015 11:14:33 -0400 Subject: [PATCH 02/16] txt record was missing rdata setter --- src/TrafficManagement/Record/TXT.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/TrafficManagement/Record/TXT.php b/src/TrafficManagement/Record/TXT.php index 56fff2d..aaba2be 100644 --- a/src/TrafficManagement/Record/TXT.php +++ b/src/TrafficManagement/Record/TXT.php @@ -44,9 +44,7 @@ public function getTxtdata() */ public function setRData(array $rdata) { - // TODO - - return $this; + $this->rdata = $rdata; } /** From c8de341f4f2978fcda0ed05184f9275e8b9da140 Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Tue, 26 May 2015 13:56:33 -0400 Subject: [PATCH 03/16] also needed txtdata set it seems. --- src/TrafficManagement/Record/TXT.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TrafficManagement/Record/TXT.php b/src/TrafficManagement/Record/TXT.php index aaba2be..707f5d9 100644 --- a/src/TrafficManagement/Record/TXT.php +++ b/src/TrafficManagement/Record/TXT.php @@ -45,6 +45,7 @@ public function getTxtdata() public function setRData(array $rdata) { $this->rdata = $rdata; + $this->txtdata = $rdata['txtdata']; } /** From caad883980e2a0a76d00f6301ec2cfe2e8b04fd2 Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Thu, 28 May 2015 16:52:45 -0400 Subject: [PATCH 04/16] added missing setRData --- src/TrafficManagement/Record/PTR.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/TrafficManagement/Record/PTR.php b/src/TrafficManagement/Record/PTR.php index f813a8b..3f89ba3 100644 --- a/src/TrafficManagement/Record/PTR.php +++ b/src/TrafficManagement/Record/PTR.php @@ -46,9 +46,7 @@ public function getPtrdname() */ public function setRData(array $rdata) { - // TODO - - return $this; + $this->setPtrdname($rdata['ptrdname']); } /** From 06a77186e1d33de8ea814d6b0cc5c89d655b8177 Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Fri, 5 Jun 2015 15:32:52 -0400 Subject: [PATCH 05/16] fixed SRV --- src/TrafficManagement/Record/SRV.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TrafficManagement/Record/SRV.php b/src/TrafficManagement/Record/SRV.php index 351ac22..ce10c8a 100644 --- a/src/TrafficManagement/Record/SRV.php +++ b/src/TrafficManagement/Record/SRV.php @@ -136,7 +136,10 @@ public function setRData(array $rdata) { // TODO - return $this; + $this->port = $rdata['port']; + $this->priority = $rdata['priority']; + $this->target = $rdata['target']; + $this->weight = $rdata['weight']; } /** From d95c633e27469b5eb5b9607af13a0378e5a35f22 Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Thu, 10 Dec 2015 16:36:11 -0500 Subject: [PATCH 06/16] added qps --- src/TrafficManagement.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/TrafficManagement.php b/src/TrafficManagement.php index a357849..53087ec 100644 --- a/src/TrafficManagement.php +++ b/src/TrafficManagement.php @@ -182,6 +182,29 @@ public function getZone($zoneName) return false; } + + /** + * @param $start int + * @param $end int + * @return bool|Zone + */ + public function getQpsJobs($start,$end) + { + $apiClient = $this->getApiClient(); + + ///QPSReport/', ); + $result = $apiClient->post( + '/QPSReport/', + ['start_ts' => $start, 'end_ts' => $end, 'breakdown' => ['zones']] + ); + + if ($result && $result->isComplete()) { + return $result; + } + + return false; + } + /** * Returns an array of all zones from the account * From b9a3063b2eee0a0670da26801de56cb77a13fb74 Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Thu, 10 Dec 2015 16:38:59 -0500 Subject: [PATCH 07/16] added qps --- src/TrafficManagement.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TrafficManagement.php b/src/TrafficManagement.php index 53087ec..97ba6b3 100644 --- a/src/TrafficManagement.php +++ b/src/TrafficManagement.php @@ -4,6 +4,7 @@ use Dyn\TrafficManagement\Api\Client as ApiClient; use Dyn\TrafficManagement\Zone; +use Symfony\Component\Config\Definition\Exception\Exception; use Zend\Http\Client as HttpClient; class TrafficManagement @@ -202,7 +203,7 @@ public function getQpsJobs($start,$end) return $result; } - return false; + throw new Exception(print_r($result,true)); } /** From c2d883dbfa09390f33801fb072efd9244ad75ac9 Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Thu, 10 Dec 2015 16:40:33 -0500 Subject: [PATCH 08/16] added qps --- src/TrafficManagement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TrafficManagement.php b/src/TrafficManagement.php index 97ba6b3..6adc233 100644 --- a/src/TrafficManagement.php +++ b/src/TrafficManagement.php @@ -203,7 +203,7 @@ public function getQpsJobs($start,$end) return $result; } - throw new Exception(print_r($result,true)); + return $apiClient->getLastHttpResponse(); } /** From bf72ae3d64dd4ef5c18339a1ca11a556c80143af Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Thu, 10 Dec 2015 16:46:40 -0500 Subject: [PATCH 09/16] added qps --- src/TrafficManagement/Api/Client.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TrafficManagement/Api/Client.php b/src/TrafficManagement/Api/Client.php index 3401e4e..e247cbd 100644 --- a/src/TrafficManagement/Api/Client.php +++ b/src/TrafficManagement/Api/Client.php @@ -157,6 +157,7 @@ public function post($path, array $data = null) { $request = $this->buildRequest($path); + print_r($request); $request->setMethod(Request::METHOD_POST); if ($data) { $request->setContent(json_encode($data)); From 1799885cb8654b49c92ab1a9b9b4fe99a98a73d5 Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Fri, 11 Dec 2015 15:10:04 -0500 Subject: [PATCH 10/16] remove debug --- src/TrafficManagement/Api/Client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TrafficManagement/Api/Client.php b/src/TrafficManagement/Api/Client.php index e247cbd..99d03f9 100644 --- a/src/TrafficManagement/Api/Client.php +++ b/src/TrafficManagement/Api/Client.php @@ -19,7 +19,7 @@ class Client extends BaseClient * Builds a request object for the given API path * * @param string $path - * @return Zend\Http\Request + * @return Request */ protected function buildRequest($path) { @@ -157,8 +157,8 @@ public function post($path, array $data = null) { $request = $this->buildRequest($path); - print_r($request); $request->setMethod(Request::METHOD_POST); + if ($data) { $request->setContent(json_encode($data)); } From a29c0f5f99edbd49278ad897a685e39c30b2d043 Mon Sep 17 00:00:00 2001 From: Bill Keenan Date: Mon, 7 Mar 2016 15:34:59 -0500 Subject: [PATCH 11/16] SPF was still called soa --- src/TrafficManagement/Record/SPF.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TrafficManagement/Record/SPF.php b/src/TrafficManagement/Record/SPF.php index 58a964b..070fa24 100644 --- a/src/TrafficManagement/Record/SPF.php +++ b/src/TrafficManagement/Record/SPF.php @@ -2,12 +2,12 @@ namespace Dyn\TrafficManagement\Record; -class SOA extends AbstractRecord +class SPF extends AbstractRecord { /** * @var string */ - protected $type = 'SOA'; + protected $type = 'SPF'; /** * SPF record information, e.g.: v=spfl mx ptr -all From de219988c664cdbaf7d9ea25f8cbd5973a496899 Mon Sep 17 00:00:00 2001 From: Junior Payne Date: Mon, 7 May 2018 13:30:17 -0400 Subject: [PATCH 12/16] DNAM-2396 --- src/TrafficManagement/Zone.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TrafficManagement/Zone.php b/src/TrafficManagement/Zone.php index 276f021..8f57f79 100644 --- a/src/TrafficManagement/Zone.php +++ b/src/TrafficManagement/Zone.php @@ -264,7 +264,9 @@ public function createRecord(RecordInterface $record, $fqdn = null) */ public function createRecordFromParams($type, $fqdn, array $params) { - $result = $this->apiClient->post('/'.$type.'Record/'.$this->getName().'/'.$fqdn.'/', $params); + //$result = $this->apiClient->post('/'.$type.'Record/'.$this->getName().'/'.$fqdn.'/', $params); changed to put from post for + //DNAM-2396 + $result = $this->apiClient->put('/'.$type.'Record/'.$this->getName().'/'.$fqdn.'/', $params); if ($result && $result->isOk()) { if ($result->isComplete()) { return true; From 112b428bafe6cb3e7bac58c5b022cd720c95f851 Mon Sep 17 00:00:00 2001 From: Junior Payne Date: Mon, 7 May 2018 14:36:09 -0400 Subject: [PATCH 13/16] Had to rollback fix because put did not work --- src/TrafficManagement/Zone.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/TrafficManagement/Zone.php b/src/TrafficManagement/Zone.php index 8f57f79..57ecdb5 100644 --- a/src/TrafficManagement/Zone.php +++ b/src/TrafficManagement/Zone.php @@ -264,9 +264,7 @@ public function createRecord(RecordInterface $record, $fqdn = null) */ public function createRecordFromParams($type, $fqdn, array $params) { - //$result = $this->apiClient->post('/'.$type.'Record/'.$this->getName().'/'.$fqdn.'/', $params); changed to put from post for - //DNAM-2396 - $result = $this->apiClient->put('/'.$type.'Record/'.$this->getName().'/'.$fqdn.'/', $params); + $result = $this->apiClient->post('/'.$type.'Record/'.$this->getName().'/'.$fqdn.'/', $params); if ($result && $result->isOk()) { if ($result->isComplete()) { return true; From e187b89f8041868320239495fa128085bfc0ea2e Mon Sep 17 00:00:00 2001 From: Junior Payne Date: Sun, 20 May 2018 13:23:00 -0400 Subject: [PATCH 14/16] DNAM-2396 --- src/TrafficManagement/Record/TXT.php | 10 +++++- src/TrafficManagement/Zone.php | 15 +++++++++ test/DynTest/TrafficManagement/ZoneTest.php | 36 +++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/TrafficManagement/Record/TXT.php b/src/TrafficManagement/Record/TXT.php index 707f5d9..83aaa9d 100644 --- a/src/TrafficManagement/Record/TXT.php +++ b/src/TrafficManagement/Record/TXT.php @@ -34,7 +34,15 @@ public function setTxtdata($txtdata) */ public function getTxtdata() { - return $this->txtdata; + return sanitizeTxtData($this->txtdata); + } + + /*filter for getting txt data so we remove any escape sequences + * mainly we are going to look for backslaches and get rid of them + */ + function sanitizeTxtData($txt){ + + return str_replace("\\","",$txt); } /** diff --git a/src/TrafficManagement/Zone.php b/src/TrafficManagement/Zone.php index 57ecdb5..c790d9a 100644 --- a/src/TrafficManagement/Zone.php +++ b/src/TrafficManagement/Zone.php @@ -233,6 +233,21 @@ public function getDefaultTtl($defaultTtl) return $this->defaultTtl; } + public function overwriteTXTRecords($records=array(),$fqdn='none'){ + + /* array( + * array($rdata => $txtdata), + * ) + * $TXTRecords['test']['txtdata'] + * $TXTRecords['ttl'] + * array TXTRecords — Required. Individual records. + hash rdata — Required. RData defining the record. + string txtdata — Required. Free form text. + string ttl — TTL for the record in seconds. Set to “0” to use zone default. + */ + //$result = $this->apiClient->put('/TXTRecord/'.$this->getName().'/'.$fqdn.'/', $params); + } + /** * Create the supplied record * diff --git a/test/DynTest/TrafficManagement/ZoneTest.php b/test/DynTest/TrafficManagement/ZoneTest.php index 7b142bb..28dea0a 100644 --- a/test/DynTest/TrafficManagement/ZoneTest.php +++ b/test/DynTest/TrafficManagement/ZoneTest.php @@ -25,6 +25,42 @@ public function setUp() $this->zone->setName('example.com'); } + public function testoverwriteTXTRecords(){ + $this->zone->overwriteTXTRecords(array(),$fqdn='example.com'); + } + + public function testoverwriteTXTRecordsWithArgs(){ + //$params = array( + // 'rdata' => $record->getRData(), + // 'ttl' => $record->getTtl() + //); + $fqdn = 'example.com'; + $rdataArray[] = array('txtdata' => 'whatevertxt'); + $rdataArray[] = array('txtdata' => 'whatevertxt2'); + $rdataArray[] = array('txtdata' => 'whatevertxt3'); + $rdataArray[] = array('txtdata' => 'whatevertxt4'); + $rparams = array( + 'rdata' => $rdataArray, + 'ttl' => 300 //$record->getTtl() + ); + $records[]= array('rdata'=>'txtdata'); + $this->zone->overwriteTXTRecords($rparams,$fqdn); + } + + public function testoverwriteTXTRecordserrorsWithoutArgs(){ + $this->zone->overwriteTXTRecords(); + } + + public function textoverwriteTXTRecordswithapicall(){ + $this->apiClient->getHttpClient()->getAdapter()->setResponse( + "HTTP/1.1 200 OK" . "\r\n" . + "Content-type: application/json" . "\r\n\r\n" . + '{"status": "success", "data": {"url": "http://example.com/other", "code": "302", "keep_uri": "False", "fqdn": "test.example.com", "zone": "example.com"}, "job_id": 12345678, "msgs": [{"INFO": "add_node: New node added to zone", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}, {"INFO": "add: Service added", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}' + ); + + + } + public function testHttpRedirectServiceCreation() { $httpRedirect = new HTTPRedirect(); From a8bbc7185f08f60337532b7d2bbab772612a980a Mon Sep 17 00:00:00 2001 From: Junior Payne Date: Sun, 20 May 2018 13:35:37 -0400 Subject: [PATCH 15/16] mistake on last commit --- src/TrafficManagement/Zone.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/TrafficManagement/Zone.php b/src/TrafficManagement/Zone.php index c790d9a..43e4d82 100644 --- a/src/TrafficManagement/Zone.php +++ b/src/TrafficManagement/Zone.php @@ -233,20 +233,6 @@ public function getDefaultTtl($defaultTtl) return $this->defaultTtl; } - public function overwriteTXTRecords($records=array(),$fqdn='none'){ - - /* array( - * array($rdata => $txtdata), - * ) - * $TXTRecords['test']['txtdata'] - * $TXTRecords['ttl'] - * array TXTRecords — Required. Individual records. - hash rdata — Required. RData defining the record. - string txtdata — Required. Free form text. - string ttl — TTL for the record in seconds. Set to “0” to use zone default. - */ - //$result = $this->apiClient->put('/TXTRecord/'.$this->getName().'/'.$fqdn.'/', $params); - } /** * Create the supplied record From 3b33a1098c09a6418cc1ec4bc104c5349ab78c3d Mon Sep 17 00:00:00 2001 From: Junior Payne Date: Mon, 21 May 2018 13:39:53 -0400 Subject: [PATCH 16/16] forgot to reference this --- src/TrafficManagement/Record/TXT.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TrafficManagement/Record/TXT.php b/src/TrafficManagement/Record/TXT.php index 83aaa9d..5d5f8f2 100644 --- a/src/TrafficManagement/Record/TXT.php +++ b/src/TrafficManagement/Record/TXT.php @@ -34,7 +34,7 @@ public function setTxtdata($txtdata) */ public function getTxtdata() { - return sanitizeTxtData($this->txtdata); + return $this->sanitizeTxtData($this->txtdata); } /*filter for getting txt data so we remove any escape sequences