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

79 lines
No EOL
3.5 KiB
PHP

<?php
namespace DigiComp\HetznerDnsApi\Endpoint;
class UpdatePrimaryServer extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
{
protected $PrimaryServerID;
/**
* Updates a primary server.
*
* @param string $primaryServerID ID of primaryServer to update
* @param null|\DigiComp\HetznerDnsApi\Model\PrimaryServer $requestBody
*/
public function __construct(string $primaryServerID, ?\DigiComp\HetznerDnsApi\Model\PrimaryServer $requestBody = null)
{
$this->PrimaryServerID = $primaryServerID;
$this->body = $requestBody;
}
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
public function getMethod() : string
{
return 'PUT';
}
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
{
if ($this->body instanceof \DigiComp\HetznerDnsApi\Model\PrimaryServer) {
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\UpdatePrimaryServerUnauthorizedException
* @throws \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerForbiddenException
* @throws \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerNotFoundException
* @throws \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerNotAcceptableException
* @throws \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerConflictException
* @throws \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerUnprocessableEntityException
*
* @return null|\DigiComp\HetznerDnsApi\Model\PrimaryServersPrimaryServerIDPutResponse200
*/
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\\PrimaryServersPrimaryServerIDPutResponse200', 'json');
}
if (401 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerUnauthorizedException();
}
if (403 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerForbiddenException();
}
if (404 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerNotFoundException();
}
if (406 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerNotAcceptableException();
}
if (409 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerConflictException();
}
if (422 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\UpdatePrimaryServerUnprocessableEntityException();
}
}
public function getAuthenticationScopes() : array
{
return array('Auth-API-Token');
}
}