Example #1
0
 public function testHttpRedirectServiceDeletion()
 {
     $httpRedirect = new HTTPRedirect();
     $httpRedirect->setFqdn('test.example.com')->setUrl('http://example.com/somethingelse')->setCode(302)->setKeepUri(false);
     // simulate the Dyn API response
     $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/somethingelse", "code": "302", "keep_uri": "", "fqdn": "test.example.com", "zone": "example.com"}, "job_id": 12345678, "msgs": [{"INFO": "update: Update successful", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}');
     $this->assertTrue($this->zone->deleteService($httpRedirect, 'test.example.com'));
 }
<?php

/**
 * This example creates a HTTP Redirect service on a zone
 */
require '../../vendor/autoload.php';
use Dyn\TrafficManagement;
use Dyn\TrafficManagement\Service\HTTPRedirect;
$tm = new TrafficManagement('customerName', 'username', 'password');
// login
$tm->createSession();
// retrieve zone
$zone = $tm->getZone('example.com');
// configure the new service
$service = new HTTPRedirect();
$service->setUri('http://example.com/someotherurl')->setCode(301)->setKeepUri(false);
// create the new service on test.example.com
$zone->createService($service, 'test.example.com');
// logout
$tm->deleteSession();