79 lines
No EOL
3.2 KiB
PHP
79 lines
No EOL
3.2 KiB
PHP
<?php
|
|
|
|
namespace DigiComp\HetznerDnsApi\Endpoint;
|
|
|
|
class UpdateZone extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
|
|
{
|
|
protected $ZoneID;
|
|
/**
|
|
* Updates a zone.
|
|
*
|
|
* @param string $zoneID ID of zone to update
|
|
* @param null|\DigiComp\HetznerDnsApi\Model\Zone $requestBody
|
|
*/
|
|
public function __construct(string $zoneID, ?\DigiComp\HetznerDnsApi\Model\Zone $requestBody = null)
|
|
{
|
|
$this->ZoneID = $zoneID;
|
|
$this->body = $requestBody;
|
|
}
|
|
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
|
|
public function getMethod() : string
|
|
{
|
|
return 'PUT';
|
|
}
|
|
public function getUri() : string
|
|
{
|
|
return str_replace(array('{ZoneID}'), array($this->ZoneID), '/zones/{ZoneID}');
|
|
}
|
|
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
|
|
{
|
|
if ($this->body instanceof \DigiComp\HetznerDnsApi\Model\Zone) {
|
|
return array(array('Content-Type' => array('application/json')), $serializer->serialize($this->body, 'json'));
|
|
}
|
|
return array(array(), null);
|
|
}
|
|
public function getExtraHeaders() : array
|
|
{
|
|
return array('Accept' => array('application/json'));
|
|
}
|
|
/**
|
|
* {@inheritdoc}
|
|
*
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateZoneUnauthorizedException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateZoneForbiddenException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateZoneNotFoundException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateZoneNotAcceptableException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateZoneConflictException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateZoneUnprocessableEntityException
|
|
*
|
|
* @return null|\DigiComp\HetznerDnsApi\Model\ZonesZoneIDPutResponse200
|
|
*/
|
|
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
|
|
{
|
|
if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
|
|
return $serializer->deserialize($body, 'DigiComp\\HetznerDnsApi\\Model\\ZonesZoneIDPutResponse200', 'json');
|
|
}
|
|
if (401 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateZoneUnauthorizedException();
|
|
}
|
|
if (403 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateZoneForbiddenException();
|
|
}
|
|
if (404 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateZoneNotFoundException();
|
|
}
|
|
if (406 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateZoneNotAcceptableException();
|
|
}
|
|
if (409 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateZoneConflictException();
|
|
}
|
|
if (422 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateZoneUnprocessableEntityException();
|
|
}
|
|
}
|
|
public function getAuthenticationScopes() : array
|
|
{
|
|
return array('Auth-API-Token');
|
|
}
|
|
} |