Domain Host API

create()

Description

Creates new host.

Signature

create(int $domain_id, DataObject\Domain\Host\Create $data_object): DataObject\Domain\Host\Existing

Throws

Example

<?php

use Dreamscape\ResellerApiSdk\Api;
use Dreamscape\ResellerApiSdk\Authenticator\ApiKey;
use Dreamscape\ResellerApiSdk\Http\Adapter\Curl;
use Dreamscape\ResellerApiSdk\DataObject;
use Dreamscape\ResellerApiSdk\Exception;

$api = new Api(new Curl(new ApiKey('YourAPIKeyGoesHere'), 'https://reseller-api.sandbox.ds.network'));

$domain_id = 123456;
$new_host = DataObject\Domain\Host\Create::build();
$new_host->host = 'some-host.crazydomains.com.au';
$new_host->ip = '27.124.125.143';

try {
    $host = $api->domains->hosts->create($domain_id, $new_host);

    echo 'Host: ' . $host->host . PHP_EOL;
    echo 'IP: ' . $host->ip . PHP_EOL;
} catch (Exception\NotFoundException $e) {
    // Handle the exception.
} catch (Exception\BadRequestException $e) {
    // Handle the errors in $e->getErrors().
}

getAll()

Description

Returns the list of hosts.

Signature

getAll(int $domain_id): DataObject\Domain\Host\Existing[]

Throws

Example

<?php

use Dreamscape\ResellerApiSdk\Api;
use Dreamscape\ResellerApiSdk\Authenticator\ApiKey;
use Dreamscape\ResellerApiSdk\Http\Adapter\Curl;
use Dreamscape\ResellerApiSdk\DataObject;
use Dreamscape\ResellerApiSdk\Exception;

$api = new Api(new Curl(new ApiKey('YourAPIKeyGoesHere'), 'https://reseller-api.sandbox.ds.network'));

$domain_id = 123456;

try {
    $hosts = $api->domains->hosts->getAll($domain_id);

    foreach ($hosts as $host) {
        echo 'Host: ' . $host->host . PHP_EOL;
        echo 'IP: ' . $host->ip . PHP_EOL;
    }
} catch (Exception\NotFoundException $e) {
    // Handle the exception.
}

getDetails()

Description

Returns the details about single host.

Signature

getDetails(int $domain_id, string $host): DataObject\Domain\Host\Existing

Throws

Example

<?php

use Dreamscape\ResellerApiSdk\Api;
use Dreamscape\ResellerApiSdk\Authenticator\ApiKey;
use Dreamscape\ResellerApiSdk\Http\Adapter\Curl;
use Dreamscape\ResellerApiSdk\DataObject;
use Dreamscape\ResellerApiSdk\Exception;

$api = new Api(new Curl(new ApiKey('YourAPIKeyGoesHere'), 'https://reseller-api.sandbox.ds.network'));

$domain_id = 123456;
$hostname = 'some-host.crazydomains.com.au';

try {
    $host = $api->domains->hosts->getDetails($domain_id, $hostname);

    echo 'Host: ' . $host->host . PHP_EOL;
    echo 'IP: ' . $host->ip . PHP_EOL;
} catch (Exception\NotFoundException $e) {
    // Handle the exception.
}

update()

Description

Updates the details for a single host.

Signature

update(int $domain_id, string $host, DataObject\Domain\Host\Update $data_object): DataObject\Domain\Host\Existing

Throws

Example

<?php

use Dreamscape\ResellerApiSdk\Api;
use Dreamscape\ResellerApiSdk\Authenticator\ApiKey;
use Dreamscape\ResellerApiSdk\Http\Adapter\Curl;
use Dreamscape\ResellerApiSdk\DataObject;
use Dreamscape\ResellerApiSdk\Exception;

$api = new Api(new Curl(new ApiKey('YourAPIKeyGoesHere'), 'https://reseller-api.sandbox.ds.network'));

$domain_id = 123456;
$hostname = 'some-host.crazydomains.com.au';
$update_host = DataObject\Domain\Host\Update::build();
$update_host->ip = '27.124.125.143';

try {
    $host = $api->domains->hosts->update($domain_id, $hostname, $update_host);

    echo 'Host: ' . $host->host . PHP_EOL;
    echo 'IP: ' . $host->ip . PHP_EOL;
} catch (Exception\NotFoundException $e) {
    // Handle the exception.
} catch (Exception\BadRequestException $e) {
    // Handle the errors in $e->getErrors().
}

delete()

Description

Deletes host.

Signature

delete(int $domain_id, string $host): bool

Throws

Example

<?php

use Dreamscape\ResellerApiSdk\Api;
use Dreamscape\ResellerApiSdk\Authenticator\ApiKey;
use Dreamscape\ResellerApiSdk\Http\Adapter\Curl;
use Dreamscape\ResellerApiSdk\DataObject;
use Dreamscape\ResellerApiSdk\Exception;

$api = new Api(new Curl(new ApiKey('YourAPIKeyGoesHere'), 'https://reseller-api.sandbox.ds.network'));

$domain_id = 123456;
$hostname = 'some-host.crazydomains.com.au';

try {
    $api->domains->hosts->delete($domain_id, $hostname);
} catch (Exception\NotFoundException $e) {
    // Handle the exception.
}