76 lines
No EOL
3.2 KiB
PHP
76 lines
No EOL
3.2 KiB
PHP
<?php
|
|
|
|
namespace DigiComp\HetznerDnsApi\Endpoint;
|
|
|
|
class BulkUpdateRecords extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
|
|
{
|
|
/**
|
|
* Update several records at once.
|
|
*
|
|
* @param null|\DigiComp\HetznerDnsApi\Model\RecordsBulkPutBody $requestBody
|
|
*/
|
|
public function __construct(?\DigiComp\HetznerDnsApi\Model\RecordsBulkPutBody $requestBody = null)
|
|
{
|
|
$this->body = $requestBody;
|
|
}
|
|
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
|
|
public function getMethod() : string
|
|
{
|
|
return 'PUT';
|
|
}
|
|
public function getUri() : string
|
|
{
|
|
return '/records/bulk';
|
|
}
|
|
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
|
|
{
|
|
if ($this->body instanceof \DigiComp\HetznerDnsApi\Model\RecordsBulkPutBody) {
|
|
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\BulkUpdateRecordsUnauthorizedException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsForbiddenException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsNotFoundException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsNotAcceptableException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsConflictException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsUnprocessableEntityException
|
|
*
|
|
* @return null|\DigiComp\HetznerDnsApi\Model\RecordsBulkPutResponse200
|
|
*/
|
|
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\\RecordsBulkPutResponse200', 'json');
|
|
}
|
|
if (401 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsUnauthorizedException();
|
|
}
|
|
if (403 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsForbiddenException();
|
|
}
|
|
if (404 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsNotFoundException();
|
|
}
|
|
if (406 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsNotAcceptableException();
|
|
}
|
|
if (409 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsConflictException();
|
|
}
|
|
if (422 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\BulkUpdateRecordsUnprocessableEntityException();
|
|
}
|
|
}
|
|
public function getAuthenticationScopes() : array
|
|
{
|
|
return array('Auth-API-Token');
|
|
}
|
|
} |