|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the Vultr PHP library. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Albert Leitato <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
namespace Vultr\Api; |
|
11
|
|
|
|
|
12
|
|
|
use Vultr\Entity\Domain as DomainEntity; |
|
13
|
|
|
use Vultr\Exceptions\HttpException; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @author Albert Leitato <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
class Domain extends AbstractApi |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* List all domains associated with the current account. |
|
22
|
|
|
* |
|
23
|
|
|
* @return DomainEntity[] |
|
24
|
|
|
*/ |
|
25
|
|
|
public function list() |
|
26
|
|
|
{ |
|
27
|
|
|
$domains = $this->adapter->get(\sprintf('%s/dns/list', $this->endpoint)); |
|
28
|
|
|
|
|
29
|
|
|
return $this->heanleResponse($domains, DomainEntity::class, true); |
|
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Create a domain name in DNS. |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $name Domain name to create |
|
36
|
|
|
* @param string $ipAddress IP to use when creating default records (A and MX) |
|
37
|
|
|
* |
|
38
|
|
|
* @throws HttpException |
|
39
|
|
|
* |
|
40
|
|
|
* @return DomainEntity |
|
41
|
|
|
*/ |
|
42
|
|
|
public function create($name, $ipAddress) |
|
43
|
|
|
{ |
|
44
|
|
|
$content = ['name' => $name, 'serverip' => $ipAddress]; |
|
45
|
|
|
|
|
46
|
|
|
$domain = $this->adapter->post(\sprintf('%s/dns/create_domain', $this->endpoint), http_build_query($content)); |
|
47
|
|
|
|
|
48
|
|
|
$domain = \json_decode($domain); |
|
49
|
|
|
|
|
50
|
|
|
return new DomainEntity($domain->domain); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Delete a domain name and all associated records. |
|
55
|
|
|
* |
|
56
|
|
|
* @param string $domain Domain name to delete |
|
57
|
|
|
* |
|
58
|
|
|
* @throws HttpException |
|
59
|
|
|
*/ |
|
60
|
|
|
public function delete($domain) |
|
61
|
|
|
{ |
|
62
|
|
|
$this->adapter->post(\sprintf('%s/dns/delete_domain', $this->endpoint), http_build_query(compact('domain'))); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.