66 lines
No EOL
2.7 KiB
PHP
66 lines
No EOL
2.7 KiB
PHP
<?php
|
|
|
|
namespace DigiComp\HetznerDnsApi\Endpoint;
|
|
|
|
class GetPrimaryServer extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
|
|
{
|
|
protected $PrimaryServerID;
|
|
/**
|
|
* Returns an object containing all information of a primary server. Primary Server to get is identified by 'PrimaryServerID'.
|
|
*
|
|
* @param string $primaryServerID ID of primary server to get
|
|
*/
|
|
public function __construct(string $primaryServerID)
|
|
{
|
|
$this->PrimaryServerID = $primaryServerID;
|
|
}
|
|
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
|
|
public function getMethod() : string
|
|
{
|
|
return 'GET';
|
|
}
|
|
public function getUri() : string
|
|
{
|
|
return str_replace(array('{PrimaryServerID}'), array($this->PrimaryServerID), '/primary_servers/{PrimaryServerID}');
|
|
}
|
|
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'));
|
|
}
|
|
/**
|
|
* {@inheritdoc}
|
|
*
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetPrimaryServerUnauthorizedException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetPrimaryServerForbiddenException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetPrimaryServerNotFoundException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetPrimaryServerNotAcceptableException
|
|
*
|
|
* @return null|\DigiComp\HetznerDnsApi\Model\PrimaryServersPrimaryServerIDGetResponse200
|
|
*/
|
|
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\\PrimaryServersPrimaryServerIDGetResponse200', 'json');
|
|
}
|
|
if (401 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetPrimaryServerUnauthorizedException();
|
|
}
|
|
if (403 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetPrimaryServerForbiddenException();
|
|
}
|
|
if (404 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetPrimaryServerNotFoundException();
|
|
}
|
|
if (406 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetPrimaryServerNotAcceptableException();
|
|
}
|
|
}
|
|
public function getAuthenticationScopes() : array
|
|
{
|
|
return array('Auth-API-Token');
|
|
}
|
|
} |