72 lines
2.8 KiB
PHP
72 lines
2.8 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace DigiComp\HetznerDnsApi\Endpoint;
|
||
|
|
||
|
class GetPrimaryServers extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
|
||
|
{
|
||
|
/**
|
||
|
* Returns all primary servers associated with user. Primary servers can also be filtered by zone_id.
|
||
|
*
|
||
|
* @param array $queryParameters {
|
||
|
* @var string $zone_id ID of zone
|
||
|
* }
|
||
|
*/
|
||
|
public function __construct(array $queryParameters = array())
|
||
|
{
|
||
|
$this->queryParameters = $queryParameters;
|
||
|
}
|
||
|
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
|
||
|
public function getMethod() : string
|
||
|
{
|
||
|
return 'GET';
|
||
|
}
|
||
|
public function getUri() : string
|
||
|
{
|
||
|
return '/primary_servers';
|
||
|
}
|
||
|
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
|
||
|
{
|
||
|
return array(array(), null);
|
||
|
}
|
||
|
public function getExtraHeaders() : array
|
||
|
{
|
||
|
return array('Accept' => array('application/json'));
|
||
|
}
|
||
|
protected function getQueryOptionsResolver() : \Symfony\Component\OptionsResolver\OptionsResolver
|
||
|
{
|
||
|
$optionsResolver = parent::getQueryOptionsResolver();
|
||
|
$optionsResolver->setDefined(array('zone_id'));
|
||
|
$optionsResolver->setRequired(array());
|
||
|
$optionsResolver->setDefaults(array());
|
||
|
$optionsResolver->setAllowedTypes('zone_id', array('string'));
|
||
|
return $optionsResolver;
|
||
|
}
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetPrimaryServersUnauthorizedException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetPrimaryServersNotFoundException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetPrimaryServersNotAcceptableException
|
||
|
*
|
||
|
* @return null|\DigiComp\HetznerDnsApi\Model\PrimaryServersGetResponse200
|
||
|
*/
|
||
|
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\\PrimaryServersGetResponse200', 'json');
|
||
|
}
|
||
|
if (401 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\GetPrimaryServersUnauthorizedException();
|
||
|
}
|
||
|
if (404 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\GetPrimaryServersNotFoundException();
|
||
|
}
|
||
|
if (406 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\GetPrimaryServersNotAcceptableException();
|
||
|
}
|
||
|
}
|
||
|
public function getAuthenticationScopes() : array
|
||
|
{
|
||
|
return array('Auth-API-Token');
|
||
|
}
|
||
|
}
|