61 lines
2.1 KiB
PHP
61 lines
2.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace DigiComp\HetznerDnsApi\Endpoint;
|
||
|
|
||
|
class ExportZoneFile extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
|
||
|
{
|
||
|
protected $ZoneID;
|
||
|
/**
|
||
|
* Export a zone file.
|
||
|
*
|
||
|
* @param string $zoneID ID of zone to be exported
|
||
|
*/
|
||
|
public function __construct(string $zoneID)
|
||
|
{
|
||
|
$this->ZoneID = $zoneID;
|
||
|
}
|
||
|
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
|
||
|
public function getMethod() : string
|
||
|
{
|
||
|
return 'GET';
|
||
|
}
|
||
|
public function getUri() : string
|
||
|
{
|
||
|
return str_replace(array('{ZoneID}'), array($this->ZoneID), '/zones/{ZoneID}/export');
|
||
|
}
|
||
|
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
|
||
|
{
|
||
|
return array(array(), null);
|
||
|
}
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\ExportZoneFileUnauthorizedException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\ExportZoneFileForbiddenException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\ExportZoneFileNotFoundException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\ExportZoneFileUnprocessableEntityException
|
||
|
*
|
||
|
* @return null
|
||
|
*/
|
||
|
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
|
||
|
{
|
||
|
if (200 === $status) {
|
||
|
}
|
||
|
if (401 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\ExportZoneFileUnauthorizedException();
|
||
|
}
|
||
|
if (403 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\ExportZoneFileForbiddenException();
|
||
|
}
|
||
|
if (404 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\ExportZoneFileNotFoundException();
|
||
|
}
|
||
|
if (422 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\ExportZoneFileUnprocessableEntityException();
|
||
|
}
|
||
|
}
|
||
|
public function getAuthenticationScopes() : array
|
||
|
{
|
||
|
return array('Auth-API-Token');
|
||
|
}
|
||
|
}
|