hetzner-dns-api/generated/Endpoint/ImportZoneFilePlain.php

67 lines
2.6 KiB
PHP
Raw Normal View History

2023-01-05 12:55:52 +01:00
<?php
namespace DigiComp\HetznerDnsApi\Endpoint;
class ImportZoneFilePlain extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
{
protected $ZoneID;
/**
* Import a zone file in text/plain format.
*
* @param string $zoneID ID of zone to be imported
* @param null|string $requestBody
*/
public function __construct(string $zoneID, ?string $requestBody = null)
{
$this->ZoneID = $zoneID;
$this->body = $requestBody;
}
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
public function getMethod() : string
{
return 'POST';
}
public function getUri() : string
{
return str_replace(array('{ZoneID}'), array($this->ZoneID), '/zones/{ZoneID}/import');
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
{
if (is_string($this->body)) {
return array(array('Content-Type' => array('text/plain')), $this->body);
}
return array(array(), null);
}
public function getExtraHeaders() : array
{
return array('Accept' => array('application/json'));
}
/**
* {@inheritdoc}
*
* @throws \DigiComp\HetznerDnsApi\Exception\ImportZoneFilePlainUnauthorizedException
* @throws \DigiComp\HetznerDnsApi\Exception\ImportZoneFilePlainNotAcceptableException
* @throws \DigiComp\HetznerDnsApi\Exception\ImportZoneFilePlainUnprocessableEntityException
*
* @return null|\DigiComp\HetznerDnsApi\Model\ZonesZoneIDImportPostResponse201
*/
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
if (is_null($contentType) === false && (201 === $status && mb_strpos($contentType, 'application/json') !== false)) {
return $serializer->deserialize($body, 'DigiComp\\HetznerDnsApi\\Model\\ZonesZoneIDImportPostResponse201', 'json');
}
if (401 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\ImportZoneFilePlainUnauthorizedException();
}
if (406 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\ImportZoneFilePlainNotAcceptableException();
}
if (422 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\ImportZoneFilePlainUnprocessableEntityException();
}
}
public function getAuthenticationScopes() : array
{
return array('Auth-API-Token');
}
}