1872 lines
90 KiB
PHP
1872 lines
90 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* PrivateNICsApi
|
||
|
|
* PHP version 7.4
|
||
|
|
*
|
||
|
|
* @category Class
|
||
|
|
* @package OpenAPI\Client
|
||
|
|
* @author OpenAPI Generator team
|
||
|
|
* @link https://openapi-generator.tech
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Instance API
|
||
|
|
*
|
||
|
|
* Scaleway Instances are virtual machines in the cloud. Different [Instance types](https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/) offer different technical specifications in terms of vCPU, RAM, bandwidth and storage. Once you have created your Instance and installed your image of choice (e.g. an operating system), you can [connect to your Instance via SSH](https://www.scaleway.com/en/docs/compute/instances/how-to/connect-to-instance/) to use it as you wish. When you are done using the Instance, you can delete it from your account. (switchcolumn) <Message type=\"tip\"> To retrieve information about the different [images](#path-images) available to install on Scaleway Instances, check out our [Marketplace API](https://www.scaleway.com/en/developers/api/marketplace). </Message> (switchcolumn) ## Concepts Refer to our [dedicated concepts page](https://www.scaleway.com/en/docs/compute/instances/concepts/) to find definitions of all concepts and terminology related to Instances. (switchcolumn) (switchcolumn) ## Quickstart 1. Configure your environment variables <Message type=\"note\"> This is an optional step that seeks to simplify your usage of the Instances API. See [Availability Zones](#availability-zones) below for help choosing an Availability Zone. You can find your Project ID in the [Scaleway console](https://console.scaleway.com/project/settings). </Message> ```bash export SCW_SECRET_KEY=\"<API secret key>\" export SCW_DEFAULT_ZONE=\"<Scaleway Availability Zone>\" export SCW_PROJECT_ID=\"<Scaleway Project ID>\" ``` 2. **Create an Instance**: Run the following command to create an Instance. You can customize the details in the payload (name, description, type, tags etc) to your needs: use the information below to adjust the payload as necessary. ```bash curl -X POST \\ -H \"X-Auth-Token: $SCW_SECRET_KEY\" \\ -H \"Content-Type: application/json\" \\ \"https://api.scaleway.com/instance/v1/zones/$SCW_DEFAULT_ZONE/servers\" \\ -d '{ \"name\": \"my-new-instance\", \"project\": \"'\"$SCW_PROJECT_ID\"'\", \"commercial_type\": \"GP1-S\", \"image\": \"ubuntu_noble\", \"enable_ipv6\": true, \"volumes\": { \"0\":{ \"size\": 300000000000, \"volume_type\": \"l_ssd\" } } }' ``` | Parameter | Description | Valid values | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `name` | A name of your choice for the Instance (string)
|
||
|
|
*
|
||
|
|
* The version of the OpenAPI document: v1
|
||
|
|
* Generated by: https://openapi-generator.tech
|
||
|
|
* Generator version: 7.11.0
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||
|
|
* https://openapi-generator.tech
|
||
|
|
* Do not edit the class manually.
|
||
|
|
*/
|
||
|
|
|
||
|
|
namespace OpenAPI\Client\Api;
|
||
|
|
|
||
|
|
use GuzzleHttp\Client;
|
||
|
|
use GuzzleHttp\ClientInterface;
|
||
|
|
use GuzzleHttp\Exception\ConnectException;
|
||
|
|
use GuzzleHttp\Exception\RequestException;
|
||
|
|
use GuzzleHttp\Psr7\MultipartStream;
|
||
|
|
use GuzzleHttp\Psr7\Request;
|
||
|
|
use GuzzleHttp\RequestOptions;
|
||
|
|
use OpenAPI\Client\ApiException;
|
||
|
|
use OpenAPI\Client\Configuration;
|
||
|
|
use OpenAPI\Client\HeaderSelector;
|
||
|
|
use OpenAPI\Client\ObjectSerializer;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* PrivateNICsApi Class Doc Comment
|
||
|
|
*
|
||
|
|
* @category Class
|
||
|
|
* @package OpenAPI\Client
|
||
|
|
* @author OpenAPI Generator team
|
||
|
|
* @link https://openapi-generator.tech
|
||
|
|
*/
|
||
|
|
class PrivateNICsApi
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @var ClientInterface
|
||
|
|
*/
|
||
|
|
protected $client;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var Configuration
|
||
|
|
*/
|
||
|
|
protected $config;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var HeaderSelector
|
||
|
|
*/
|
||
|
|
protected $headerSelector;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var int Host index
|
||
|
|
*/
|
||
|
|
protected $hostIndex;
|
||
|
|
|
||
|
|
/** @var string[] $contentTypes **/
|
||
|
|
public const contentTypes = [
|
||
|
|
'createPrivateNIC' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'deletePrivateNIC' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'getPrivateNIC' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'listPrivateNICs' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'updatePrivateNIC' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param ClientInterface $client
|
||
|
|
* @param Configuration $config
|
||
|
|
* @param HeaderSelector $selector
|
||
|
|
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
|
||
|
|
*/
|
||
|
|
public function __construct(
|
||
|
|
?ClientInterface $client = null,
|
||
|
|
?Configuration $config = null,
|
||
|
|
?HeaderSelector $selector = null,
|
||
|
|
int $hostIndex = 0
|
||
|
|
) {
|
||
|
|
$this->client = $client ?: new Client();
|
||
|
|
$this->config = $config ?: Configuration::getDefaultConfiguration();
|
||
|
|
$this->headerSelector = $selector ?: new HeaderSelector();
|
||
|
|
$this->hostIndex = $hostIndex;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Set the host index
|
||
|
|
*
|
||
|
|
* @param int $hostIndex Host index (required)
|
||
|
|
*/
|
||
|
|
public function setHostIndex($hostIndex): void
|
||
|
|
{
|
||
|
|
$this->hostIndex = $hostIndex;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the host index
|
||
|
|
*
|
||
|
|
* @return int Host index
|
||
|
|
*/
|
||
|
|
public function getHostIndex()
|
||
|
|
{
|
||
|
|
return $this->hostIndex;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return Configuration
|
||
|
|
*/
|
||
|
|
public function getConfig()
|
||
|
|
{
|
||
|
|
return $this->config;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createPrivateNIC
|
||
|
|
*
|
||
|
|
* Create a private NIC connecting an Instance to a Private Network
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreatePrivateNICRequest $create_private_nic_request create_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \OpenAPI\Client\Model\ScalewayInstanceV1CreatePrivateNICResponse
|
||
|
|
*/
|
||
|
|
public function createPrivateNIC($zone, $server_id, $create_private_nic_request, string $contentType = self::contentTypes['createPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->createPrivateNICWithHttpInfo($zone, $server_id, $create_private_nic_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createPrivateNICWithHttpInfo
|
||
|
|
*
|
||
|
|
* Create a private NIC connecting an Instance to a Private Network
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreatePrivateNICRequest $create_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return array of \OpenAPI\Client\Model\ScalewayInstanceV1CreatePrivateNICResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function createPrivateNICWithHttpInfo($zone, $server_id, $create_private_nic_request, string $contentType = self::contentTypes['createPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
$request = $this->createPrivateNICRequest($zone, $server_id, $create_private_nic_request, $contentType);
|
||
|
|
|
||
|
|
try {
|
||
|
|
$options = $this->createHttpClientOption();
|
||
|
|
try {
|
||
|
|
$response = $this->client->send($request, $options);
|
||
|
|
} catch (RequestException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
|
||
|
|
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
|
||
|
|
);
|
||
|
|
} catch (ConnectException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
null,
|
||
|
|
null
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
|
||
|
|
|
||
|
|
switch($statusCode) {
|
||
|
|
case 201:
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1CreatePrivateNICResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1CreatePrivateNICResponse' !== 'string') {
|
||
|
|
try {
|
||
|
|
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
|
||
|
|
} catch (\JsonException $exception) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'Error JSON decoding server response (%s)',
|
||
|
|
$request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
$content
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ScalewayInstanceV1CreatePrivateNICResponse', []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($statusCode < 200 || $statusCode > 299) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
(string) $request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1CreatePrivateNICResponse';
|
||
|
|
if ($returnType === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ($returnType !== 'string') {
|
||
|
|
try {
|
||
|
|
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
|
||
|
|
} catch (\JsonException $exception) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'Error JSON decoding server response (%s)',
|
||
|
|
$request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
$content
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, $returnType, []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
|
||
|
|
} catch (ApiException $e) {
|
||
|
|
switch ($e->getCode()) {
|
||
|
|
case 201:
|
||
|
|
$data = ObjectSerializer::deserialize(
|
||
|
|
$e->getResponseBody(),
|
||
|
|
'\OpenAPI\Client\Model\ScalewayInstanceV1CreatePrivateNICResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createPrivateNICAsync
|
||
|
|
*
|
||
|
|
* Create a private NIC connecting an Instance to a Private Network
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreatePrivateNICRequest $create_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function createPrivateNICAsync($zone, $server_id, $create_private_nic_request, string $contentType = self::contentTypes['createPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
return $this->createPrivateNICAsyncWithHttpInfo($zone, $server_id, $create_private_nic_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createPrivateNICAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Create a private NIC connecting an Instance to a Private Network
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreatePrivateNICRequest $create_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function createPrivateNICAsyncWithHttpInfo($zone, $server_id, $create_private_nic_request, string $contentType = self::contentTypes['createPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1CreatePrivateNICResponse';
|
||
|
|
$request = $this->createPrivateNICRequest($zone, $server_id, $create_private_nic_request, $contentType);
|
||
|
|
|
||
|
|
return $this->client
|
||
|
|
->sendAsync($request, $this->createHttpClientOption())
|
||
|
|
->then(
|
||
|
|
function ($response) use ($returnType) {
|
||
|
|
if ($returnType === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ($returnType !== 'string') {
|
||
|
|
$content = json_decode($content);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, $returnType, []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
},
|
||
|
|
function ($exception) {
|
||
|
|
$response = $exception->getResponse();
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
$exception->getRequest()->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create request for operation 'createPrivateNIC'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreatePrivateNICRequest $create_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function createPrivateNICRequest($zone, $server_id, $create_private_nic_request, string $contentType = self::contentTypes['createPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
|
||
|
|
// verify the required parameter 'zone' is set
|
||
|
|
if ($zone === null || (is_array($zone) && count($zone) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $zone when calling createPrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'server_id' is set
|
||
|
|
if ($server_id === null || (is_array($server_id) && count($server_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $server_id when calling createPrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'create_private_nic_request' is set
|
||
|
|
if ($create_private_nic_request === null || (is_array($create_private_nic_request) && count($create_private_nic_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $create_private_nic_request when calling createPrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/servers/{server_id}/private_nics';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($server_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'server_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($server_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (isset($create_private_nic_request)) {
|
||
|
|
if (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the body
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($create_private_nic_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $create_private_nic_request;
|
||
|
|
}
|
||
|
|
} elseif (count($formParams) > 0) {
|
||
|
|
if ($multipart) {
|
||
|
|
$multipartContents = [];
|
||
|
|
foreach ($formParams as $formParamName => $formParamValue) {
|
||
|
|
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
|
||
|
|
foreach ($formParamValueItems as $formParamValueItem) {
|
||
|
|
$multipartContents[] = [
|
||
|
|
'name' => $formParamName,
|
||
|
|
'contents' => $formParamValueItem
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = new MultipartStream($multipartContents);
|
||
|
|
|
||
|
|
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the form parameters
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
|
||
|
|
} else {
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = ObjectSerializer::buildQuery($formParams);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// this endpoint requires API key authentication
|
||
|
|
$apiKey = $this->config->getApiKeyWithPrefix('X-Auth-Token');
|
||
|
|
if ($apiKey !== null) {
|
||
|
|
$headers['X-Auth-Token'] = $apiKey;
|
||
|
|
}
|
||
|
|
|
||
|
|
$defaultHeaders = [];
|
||
|
|
if ($this->config->getUserAgent()) {
|
||
|
|
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||
|
|
}
|
||
|
|
|
||
|
|
$headers = array_merge(
|
||
|
|
$defaultHeaders,
|
||
|
|
$headerParams,
|
||
|
|
$headers
|
||
|
|
);
|
||
|
|
|
||
|
|
$operationHost = $this->config->getHost();
|
||
|
|
$query = ObjectSerializer::buildQuery($queryParams);
|
||
|
|
return new Request(
|
||
|
|
'POST',
|
||
|
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
||
|
|
$headers,
|
||
|
|
$httpBody
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deletePrivateNIC
|
||
|
|
*
|
||
|
|
* Delete a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function deletePrivateNIC($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['deletePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
$this->deletePrivateNICWithHttpInfo($zone, $server_id, $private_nic_id, $contentType);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deletePrivateNICWithHttpInfo
|
||
|
|
*
|
||
|
|
* Delete a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return array of null, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function deletePrivateNICWithHttpInfo($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['deletePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
$request = $this->deletePrivateNICRequest($zone, $server_id, $private_nic_id, $contentType);
|
||
|
|
|
||
|
|
try {
|
||
|
|
$options = $this->createHttpClientOption();
|
||
|
|
try {
|
||
|
|
$response = $this->client->send($request, $options);
|
||
|
|
} catch (RequestException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
|
||
|
|
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
|
||
|
|
);
|
||
|
|
} catch (ConnectException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
null,
|
||
|
|
null
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
|
||
|
|
|
||
|
|
return [null, $statusCode, $response->getHeaders()];
|
||
|
|
|
||
|
|
} catch (ApiException $e) {
|
||
|
|
switch ($e->getCode()) {
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deletePrivateNICAsync
|
||
|
|
*
|
||
|
|
* Delete a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function deletePrivateNICAsync($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['deletePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
return $this->deletePrivateNICAsyncWithHttpInfo($zone, $server_id, $private_nic_id, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deletePrivateNICAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Delete a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function deletePrivateNICAsyncWithHttpInfo($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['deletePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
$returnType = '';
|
||
|
|
$request = $this->deletePrivateNICRequest($zone, $server_id, $private_nic_id, $contentType);
|
||
|
|
|
||
|
|
return $this->client
|
||
|
|
->sendAsync($request, $this->createHttpClientOption())
|
||
|
|
->then(
|
||
|
|
function ($response) use ($returnType) {
|
||
|
|
return [null, $response->getStatusCode(), $response->getHeaders()];
|
||
|
|
},
|
||
|
|
function ($exception) {
|
||
|
|
$response = $exception->getResponse();
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
$exception->getRequest()->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create request for operation 'deletePrivateNIC'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function deletePrivateNICRequest($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['deletePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
|
||
|
|
// verify the required parameter 'zone' is set
|
||
|
|
if ($zone === null || (is_array($zone) && count($zone) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $zone when calling deletePrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'server_id' is set
|
||
|
|
if ($server_id === null || (is_array($server_id) && count($server_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $server_id when calling deletePrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'private_nic_id' is set
|
||
|
|
if ($private_nic_id === null || (is_array($private_nic_id) && count($private_nic_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $private_nic_id when calling deletePrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/servers/{server_id}/private_nics/{private_nic_id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($server_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'server_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($server_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($private_nic_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'private_nic_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($private_nic_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
[],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (count($formParams) > 0) {
|
||
|
|
if ($multipart) {
|
||
|
|
$multipartContents = [];
|
||
|
|
foreach ($formParams as $formParamName => $formParamValue) {
|
||
|
|
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
|
||
|
|
foreach ($formParamValueItems as $formParamValueItem) {
|
||
|
|
$multipartContents[] = [
|
||
|
|
'name' => $formParamName,
|
||
|
|
'contents' => $formParamValueItem
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = new MultipartStream($multipartContents);
|
||
|
|
|
||
|
|
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the form parameters
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
|
||
|
|
} else {
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = ObjectSerializer::buildQuery($formParams);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// this endpoint requires API key authentication
|
||
|
|
$apiKey = $this->config->getApiKeyWithPrefix('X-Auth-Token');
|
||
|
|
if ($apiKey !== null) {
|
||
|
|
$headers['X-Auth-Token'] = $apiKey;
|
||
|
|
}
|
||
|
|
|
||
|
|
$defaultHeaders = [];
|
||
|
|
if ($this->config->getUserAgent()) {
|
||
|
|
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||
|
|
}
|
||
|
|
|
||
|
|
$headers = array_merge(
|
||
|
|
$defaultHeaders,
|
||
|
|
$headerParams,
|
||
|
|
$headers
|
||
|
|
);
|
||
|
|
|
||
|
|
$operationHost = $this->config->getHost();
|
||
|
|
$query = ObjectSerializer::buildQuery($queryParams);
|
||
|
|
return new Request(
|
||
|
|
'DELETE',
|
||
|
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
||
|
|
$headers,
|
||
|
|
$httpBody
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getPrivateNIC
|
||
|
|
*
|
||
|
|
* Get a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \OpenAPI\Client\Model\ScalewayInstanceV1GetPrivateNICResponse
|
||
|
|
*/
|
||
|
|
public function getPrivateNIC($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['getPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->getPrivateNICWithHttpInfo($zone, $server_id, $private_nic_id, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getPrivateNICWithHttpInfo
|
||
|
|
*
|
||
|
|
* Get a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return array of \OpenAPI\Client\Model\ScalewayInstanceV1GetPrivateNICResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function getPrivateNICWithHttpInfo($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['getPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
$request = $this->getPrivateNICRequest($zone, $server_id, $private_nic_id, $contentType);
|
||
|
|
|
||
|
|
try {
|
||
|
|
$options = $this->createHttpClientOption();
|
||
|
|
try {
|
||
|
|
$response = $this->client->send($request, $options);
|
||
|
|
} catch (RequestException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
|
||
|
|
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
|
||
|
|
);
|
||
|
|
} catch (ConnectException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
null,
|
||
|
|
null
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
|
||
|
|
|
||
|
|
switch($statusCode) {
|
||
|
|
case 200:
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1GetPrivateNICResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1GetPrivateNICResponse' !== 'string') {
|
||
|
|
try {
|
||
|
|
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
|
||
|
|
} catch (\JsonException $exception) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'Error JSON decoding server response (%s)',
|
||
|
|
$request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
$content
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ScalewayInstanceV1GetPrivateNICResponse', []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($statusCode < 200 || $statusCode > 299) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
(string) $request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1GetPrivateNICResponse';
|
||
|
|
if ($returnType === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ($returnType !== 'string') {
|
||
|
|
try {
|
||
|
|
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
|
||
|
|
} catch (\JsonException $exception) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'Error JSON decoding server response (%s)',
|
||
|
|
$request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
$content
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, $returnType, []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
|
||
|
|
} catch (ApiException $e) {
|
||
|
|
switch ($e->getCode()) {
|
||
|
|
case 200:
|
||
|
|
$data = ObjectSerializer::deserialize(
|
||
|
|
$e->getResponseBody(),
|
||
|
|
'\OpenAPI\Client\Model\ScalewayInstanceV1GetPrivateNICResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getPrivateNICAsync
|
||
|
|
*
|
||
|
|
* Get a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function getPrivateNICAsync($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['getPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
return $this->getPrivateNICAsyncWithHttpInfo($zone, $server_id, $private_nic_id, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getPrivateNICAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Get a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function getPrivateNICAsyncWithHttpInfo($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['getPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1GetPrivateNICResponse';
|
||
|
|
$request = $this->getPrivateNICRequest($zone, $server_id, $private_nic_id, $contentType);
|
||
|
|
|
||
|
|
return $this->client
|
||
|
|
->sendAsync($request, $this->createHttpClientOption())
|
||
|
|
->then(
|
||
|
|
function ($response) use ($returnType) {
|
||
|
|
if ($returnType === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ($returnType !== 'string') {
|
||
|
|
$content = json_decode($content);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, $returnType, []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
},
|
||
|
|
function ($exception) {
|
||
|
|
$response = $exception->getResponse();
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
$exception->getRequest()->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create request for operation 'getPrivateNIC'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function getPrivateNICRequest($zone, $server_id, $private_nic_id, string $contentType = self::contentTypes['getPrivateNIC'][0])
|
||
|
|
{
|
||
|
|
|
||
|
|
// verify the required parameter 'zone' is set
|
||
|
|
if ($zone === null || (is_array($zone) && count($zone) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $zone when calling getPrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'server_id' is set
|
||
|
|
if ($server_id === null || (is_array($server_id) && count($server_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $server_id when calling getPrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'private_nic_id' is set
|
||
|
|
if ($private_nic_id === null || (is_array($private_nic_id) && count($private_nic_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $private_nic_id when calling getPrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/servers/{server_id}/private_nics/{private_nic_id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($server_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'server_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($server_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($private_nic_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'private_nic_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($private_nic_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (count($formParams) > 0) {
|
||
|
|
if ($multipart) {
|
||
|
|
$multipartContents = [];
|
||
|
|
foreach ($formParams as $formParamName => $formParamValue) {
|
||
|
|
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
|
||
|
|
foreach ($formParamValueItems as $formParamValueItem) {
|
||
|
|
$multipartContents[] = [
|
||
|
|
'name' => $formParamName,
|
||
|
|
'contents' => $formParamValueItem
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = new MultipartStream($multipartContents);
|
||
|
|
|
||
|
|
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the form parameters
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
|
||
|
|
} else {
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = ObjectSerializer::buildQuery($formParams);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// this endpoint requires API key authentication
|
||
|
|
$apiKey = $this->config->getApiKeyWithPrefix('X-Auth-Token');
|
||
|
|
if ($apiKey !== null) {
|
||
|
|
$headers['X-Auth-Token'] = $apiKey;
|
||
|
|
}
|
||
|
|
|
||
|
|
$defaultHeaders = [];
|
||
|
|
if ($this->config->getUserAgent()) {
|
||
|
|
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||
|
|
}
|
||
|
|
|
||
|
|
$headers = array_merge(
|
||
|
|
$defaultHeaders,
|
||
|
|
$headerParams,
|
||
|
|
$headers
|
||
|
|
);
|
||
|
|
|
||
|
|
$operationHost = $this->config->getHost();
|
||
|
|
$query = ObjectSerializer::buildQuery($queryParams);
|
||
|
|
return new Request(
|
||
|
|
'GET',
|
||
|
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
||
|
|
$headers,
|
||
|
|
$httpBody
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listPrivateNICs
|
||
|
|
*
|
||
|
|
* List all private NICs
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string|null $tags Private NIC tags. (optional)
|
||
|
|
* @param int|null $per_page A positive integer lower or equal to 100 to select the number of items to return. (optional)
|
||
|
|
* @param int|null $page A positive integer to choose the page to return. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrivateNICs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \OpenAPI\Client\Model\ScalewayInstanceV1ListPrivateNICsResponse
|
||
|
|
*/
|
||
|
|
public function listPrivateNICs($zone, $server_id, $tags = null, $per_page = null, $page = null, string $contentType = self::contentTypes['listPrivateNICs'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->listPrivateNICsWithHttpInfo($zone, $server_id, $tags, $per_page, $page, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listPrivateNICsWithHttpInfo
|
||
|
|
*
|
||
|
|
* List all private NICs
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string|null $tags Private NIC tags. (optional)
|
||
|
|
* @param int|null $per_page A positive integer lower or equal to 100 to select the number of items to return. (optional)
|
||
|
|
* @param int|null $page A positive integer to choose the page to return. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrivateNICs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return array of \OpenAPI\Client\Model\ScalewayInstanceV1ListPrivateNICsResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function listPrivateNICsWithHttpInfo($zone, $server_id, $tags = null, $per_page = null, $page = null, string $contentType = self::contentTypes['listPrivateNICs'][0])
|
||
|
|
{
|
||
|
|
$request = $this->listPrivateNICsRequest($zone, $server_id, $tags, $per_page, $page, $contentType);
|
||
|
|
|
||
|
|
try {
|
||
|
|
$options = $this->createHttpClientOption();
|
||
|
|
try {
|
||
|
|
$response = $this->client->send($request, $options);
|
||
|
|
} catch (RequestException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
|
||
|
|
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
|
||
|
|
);
|
||
|
|
} catch (ConnectException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
null,
|
||
|
|
null
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
|
||
|
|
|
||
|
|
switch($statusCode) {
|
||
|
|
case 200:
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1ListPrivateNICsResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1ListPrivateNICsResponse' !== 'string') {
|
||
|
|
try {
|
||
|
|
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
|
||
|
|
} catch (\JsonException $exception) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'Error JSON decoding server response (%s)',
|
||
|
|
$request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
$content
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ScalewayInstanceV1ListPrivateNICsResponse', []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($statusCode < 200 || $statusCode > 299) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
(string) $request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1ListPrivateNICsResponse';
|
||
|
|
if ($returnType === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ($returnType !== 'string') {
|
||
|
|
try {
|
||
|
|
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
|
||
|
|
} catch (\JsonException $exception) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'Error JSON decoding server response (%s)',
|
||
|
|
$request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
$content
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, $returnType, []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
|
||
|
|
} catch (ApiException $e) {
|
||
|
|
switch ($e->getCode()) {
|
||
|
|
case 200:
|
||
|
|
$data = ObjectSerializer::deserialize(
|
||
|
|
$e->getResponseBody(),
|
||
|
|
'\OpenAPI\Client\Model\ScalewayInstanceV1ListPrivateNICsResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listPrivateNICsAsync
|
||
|
|
*
|
||
|
|
* List all private NICs
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string|null $tags Private NIC tags. (optional)
|
||
|
|
* @param int|null $per_page A positive integer lower or equal to 100 to select the number of items to return. (optional)
|
||
|
|
* @param int|null $page A positive integer to choose the page to return. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrivateNICs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function listPrivateNICsAsync($zone, $server_id, $tags = null, $per_page = null, $page = null, string $contentType = self::contentTypes['listPrivateNICs'][0])
|
||
|
|
{
|
||
|
|
return $this->listPrivateNICsAsyncWithHttpInfo($zone, $server_id, $tags, $per_page, $page, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listPrivateNICsAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* List all private NICs
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string|null $tags Private NIC tags. (optional)
|
||
|
|
* @param int|null $per_page A positive integer lower or equal to 100 to select the number of items to return. (optional)
|
||
|
|
* @param int|null $page A positive integer to choose the page to return. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrivateNICs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function listPrivateNICsAsyncWithHttpInfo($zone, $server_id, $tags = null, $per_page = null, $page = null, string $contentType = self::contentTypes['listPrivateNICs'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1ListPrivateNICsResponse';
|
||
|
|
$request = $this->listPrivateNICsRequest($zone, $server_id, $tags, $per_page, $page, $contentType);
|
||
|
|
|
||
|
|
return $this->client
|
||
|
|
->sendAsync($request, $this->createHttpClientOption())
|
||
|
|
->then(
|
||
|
|
function ($response) use ($returnType) {
|
||
|
|
if ($returnType === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ($returnType !== 'string') {
|
||
|
|
$content = json_decode($content);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, $returnType, []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
},
|
||
|
|
function ($exception) {
|
||
|
|
$response = $exception->getResponse();
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
$exception->getRequest()->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create request for operation 'listPrivateNICs'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id Instance to which the private NIC is attached. (required)
|
||
|
|
* @param string|null $tags Private NIC tags. (optional)
|
||
|
|
* @param int|null $per_page A positive integer lower or equal to 100 to select the number of items to return. (optional)
|
||
|
|
* @param int|null $page A positive integer to choose the page to return. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrivateNICs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function listPrivateNICsRequest($zone, $server_id, $tags = null, $per_page = null, $page = null, string $contentType = self::contentTypes['listPrivateNICs'][0])
|
||
|
|
{
|
||
|
|
|
||
|
|
// verify the required parameter 'zone' is set
|
||
|
|
if ($zone === null || (is_array($zone) && count($zone) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $zone when calling listPrivateNICs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'server_id' is set
|
||
|
|
if ($server_id === null || (is_array($server_id) && count($server_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $server_id when calling listPrivateNICs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/servers/{server_id}/private_nics';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
// query params
|
||
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
||
|
|
$tags,
|
||
|
|
'tags', // param base name
|
||
|
|
'string', // openApiType
|
||
|
|
'form', // style
|
||
|
|
true, // explode
|
||
|
|
false // required
|
||
|
|
) ?? []);
|
||
|
|
// query params
|
||
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
||
|
|
$per_page,
|
||
|
|
'per_page', // param base name
|
||
|
|
'integer', // openApiType
|
||
|
|
'form', // style
|
||
|
|
true, // explode
|
||
|
|
false // required
|
||
|
|
) ?? []);
|
||
|
|
// query params
|
||
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
||
|
|
$page,
|
||
|
|
'page', // param base name
|
||
|
|
'integer', // openApiType
|
||
|
|
'form', // style
|
||
|
|
true, // explode
|
||
|
|
false // required
|
||
|
|
) ?? []);
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($server_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'server_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($server_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (count($formParams) > 0) {
|
||
|
|
if ($multipart) {
|
||
|
|
$multipartContents = [];
|
||
|
|
foreach ($formParams as $formParamName => $formParamValue) {
|
||
|
|
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
|
||
|
|
foreach ($formParamValueItems as $formParamValueItem) {
|
||
|
|
$multipartContents[] = [
|
||
|
|
'name' => $formParamName,
|
||
|
|
'contents' => $formParamValueItem
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = new MultipartStream($multipartContents);
|
||
|
|
|
||
|
|
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the form parameters
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
|
||
|
|
} else {
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = ObjectSerializer::buildQuery($formParams);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// this endpoint requires API key authentication
|
||
|
|
$apiKey = $this->config->getApiKeyWithPrefix('X-Auth-Token');
|
||
|
|
if ($apiKey !== null) {
|
||
|
|
$headers['X-Auth-Token'] = $apiKey;
|
||
|
|
}
|
||
|
|
|
||
|
|
$defaultHeaders = [];
|
||
|
|
if ($this->config->getUserAgent()) {
|
||
|
|
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||
|
|
}
|
||
|
|
|
||
|
|
$headers = array_merge(
|
||
|
|
$defaultHeaders,
|
||
|
|
$headerParams,
|
||
|
|
$headers
|
||
|
|
);
|
||
|
|
|
||
|
|
$operationHost = $this->config->getHost();
|
||
|
|
$query = ObjectSerializer::buildQuery($queryParams);
|
||
|
|
return new Request(
|
||
|
|
'GET',
|
||
|
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
||
|
|
$headers,
|
||
|
|
$httpBody
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updatePrivateNIC
|
||
|
|
*
|
||
|
|
* Update a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdatePrivateNICRequest $update_private_nic_request update_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \OpenAPI\Client\Model\ScalewayInstanceV1PrivateNIC
|
||
|
|
*/
|
||
|
|
public function updatePrivateNIC($zone, $server_id, $private_nic_id, $update_private_nic_request, string $contentType = self::contentTypes['updatePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->updatePrivateNICWithHttpInfo($zone, $server_id, $private_nic_id, $update_private_nic_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updatePrivateNICWithHttpInfo
|
||
|
|
*
|
||
|
|
* Update a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdatePrivateNICRequest $update_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return array of \OpenAPI\Client\Model\ScalewayInstanceV1PrivateNIC, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function updatePrivateNICWithHttpInfo($zone, $server_id, $private_nic_id, $update_private_nic_request, string $contentType = self::contentTypes['updatePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
$request = $this->updatePrivateNICRequest($zone, $server_id, $private_nic_id, $update_private_nic_request, $contentType);
|
||
|
|
|
||
|
|
try {
|
||
|
|
$options = $this->createHttpClientOption();
|
||
|
|
try {
|
||
|
|
$response = $this->client->send($request, $options);
|
||
|
|
} catch (RequestException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
|
||
|
|
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
|
||
|
|
);
|
||
|
|
} catch (ConnectException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
null,
|
||
|
|
null
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
|
||
|
|
|
||
|
|
switch($statusCode) {
|
||
|
|
case 200:
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1PrivateNIC' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1PrivateNIC' !== 'string') {
|
||
|
|
try {
|
||
|
|
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
|
||
|
|
} catch (\JsonException $exception) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'Error JSON decoding server response (%s)',
|
||
|
|
$request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
$content
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ScalewayInstanceV1PrivateNIC', []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($statusCode < 200 || $statusCode > 299) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
(string) $request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1PrivateNIC';
|
||
|
|
if ($returnType === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ($returnType !== 'string') {
|
||
|
|
try {
|
||
|
|
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
|
||
|
|
} catch (\JsonException $exception) {
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'Error JSON decoding server response (%s)',
|
||
|
|
$request->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
$content
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, $returnType, []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
|
||
|
|
} catch (ApiException $e) {
|
||
|
|
switch ($e->getCode()) {
|
||
|
|
case 200:
|
||
|
|
$data = ObjectSerializer::deserialize(
|
||
|
|
$e->getResponseBody(),
|
||
|
|
'\OpenAPI\Client\Model\ScalewayInstanceV1PrivateNIC',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updatePrivateNICAsync
|
||
|
|
*
|
||
|
|
* Update a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdatePrivateNICRequest $update_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function updatePrivateNICAsync($zone, $server_id, $private_nic_id, $update_private_nic_request, string $contentType = self::contentTypes['updatePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
return $this->updatePrivateNICAsyncWithHttpInfo($zone, $server_id, $private_nic_id, $update_private_nic_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updatePrivateNICAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Update a private NIC
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdatePrivateNICRequest $update_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function updatePrivateNICAsyncWithHttpInfo($zone, $server_id, $private_nic_id, $update_private_nic_request, string $contentType = self::contentTypes['updatePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1PrivateNIC';
|
||
|
|
$request = $this->updatePrivateNICRequest($zone, $server_id, $private_nic_id, $update_private_nic_request, $contentType);
|
||
|
|
|
||
|
|
return $this->client
|
||
|
|
->sendAsync($request, $this->createHttpClientOption())
|
||
|
|
->then(
|
||
|
|
function ($response) use ($returnType) {
|
||
|
|
if ($returnType === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ($returnType !== 'string') {
|
||
|
|
$content = json_decode($content);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
ObjectSerializer::deserialize($content, $returnType, []),
|
||
|
|
$response->getStatusCode(),
|
||
|
|
$response->getHeaders()
|
||
|
|
];
|
||
|
|
},
|
||
|
|
function ($exception) {
|
||
|
|
$response = $exception->getResponse();
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
$exception->getRequest()->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create request for operation 'updatePrivateNIC'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $server_id UUID of the Instance the private NIC will be attached to. (required)
|
||
|
|
* @param string $private_nic_id Private NIC unique ID. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdatePrivateNICRequest $update_private_nic_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrivateNIC'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function updatePrivateNICRequest($zone, $server_id, $private_nic_id, $update_private_nic_request, string $contentType = self::contentTypes['updatePrivateNIC'][0])
|
||
|
|
{
|
||
|
|
|
||
|
|
// verify the required parameter 'zone' is set
|
||
|
|
if ($zone === null || (is_array($zone) && count($zone) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $zone when calling updatePrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'server_id' is set
|
||
|
|
if ($server_id === null || (is_array($server_id) && count($server_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $server_id when calling updatePrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'private_nic_id' is set
|
||
|
|
if ($private_nic_id === null || (is_array($private_nic_id) && count($private_nic_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $private_nic_id when calling updatePrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'update_private_nic_request' is set
|
||
|
|
if ($update_private_nic_request === null || (is_array($update_private_nic_request) && count($update_private_nic_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $update_private_nic_request when calling updatePrivateNIC'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/servers/{server_id}/private_nics/{private_nic_id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($server_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'server_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($server_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($private_nic_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'private_nic_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($private_nic_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (isset($update_private_nic_request)) {
|
||
|
|
if (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the body
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_private_nic_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $update_private_nic_request;
|
||
|
|
}
|
||
|
|
} elseif (count($formParams) > 0) {
|
||
|
|
if ($multipart) {
|
||
|
|
$multipartContents = [];
|
||
|
|
foreach ($formParams as $formParamName => $formParamValue) {
|
||
|
|
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
|
||
|
|
foreach ($formParamValueItems as $formParamValueItem) {
|
||
|
|
$multipartContents[] = [
|
||
|
|
'name' => $formParamName,
|
||
|
|
'contents' => $formParamValueItem
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = new MultipartStream($multipartContents);
|
||
|
|
|
||
|
|
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the form parameters
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
|
||
|
|
} else {
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = ObjectSerializer::buildQuery($formParams);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// this endpoint requires API key authentication
|
||
|
|
$apiKey = $this->config->getApiKeyWithPrefix('X-Auth-Token');
|
||
|
|
if ($apiKey !== null) {
|
||
|
|
$headers['X-Auth-Token'] = $apiKey;
|
||
|
|
}
|
||
|
|
|
||
|
|
$defaultHeaders = [];
|
||
|
|
if ($this->config->getUserAgent()) {
|
||
|
|
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||
|
|
}
|
||
|
|
|
||
|
|
$headers = array_merge(
|
||
|
|
$defaultHeaders,
|
||
|
|
$headerParams,
|
||
|
|
$headers
|
||
|
|
);
|
||
|
|
|
||
|
|
$operationHost = $this->config->getHost();
|
||
|
|
$query = ObjectSerializer::buildQuery($queryParams);
|
||
|
|
return new Request(
|
||
|
|
'PATCH',
|
||
|
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
||
|
|
$headers,
|
||
|
|
$httpBody
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create http client option
|
||
|
|
*
|
||
|
|
* @throws \RuntimeException on file opening failure
|
||
|
|
* @return array of http client options
|
||
|
|
*/
|
||
|
|
protected function createHttpClientOption()
|
||
|
|
{
|
||
|
|
$options = [];
|
||
|
|
if ($this->config->getDebug()) {
|
||
|
|
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
|
||
|
|
if (!$options[RequestOptions::DEBUG]) {
|
||
|
|
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return $options;
|
||
|
|
}
|
||
|
|
}
|