2766 lines
125 KiB
PHP
2766 lines
125 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* VolumesApi
|
||
|
|
* 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;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* VolumesApi Class Doc Comment
|
||
|
|
*
|
||
|
|
* @category Class
|
||
|
|
* @package OpenAPI\Client
|
||
|
|
* @author OpenAPI Generator team
|
||
|
|
* @link https://openapi-generator.tech
|
||
|
|
*/
|
||
|
|
class VolumesApi
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @var ClientInterface
|
||
|
|
*/
|
||
|
|
protected $client;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var Configuration
|
||
|
|
*/
|
||
|
|
protected $config;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var HeaderSelector
|
||
|
|
*/
|
||
|
|
protected $headerSelector;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var int Host index
|
||
|
|
*/
|
||
|
|
protected $hostIndex;
|
||
|
|
|
||
|
|
/** @var string[] $contentTypes **/
|
||
|
|
public const contentTypes = [
|
||
|
|
'applyBlockMigration' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'createVolume' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'deleteVolume' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'getVolume' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'listVolumes' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'planBlockMigration' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'setVolume' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'updateVolume' => [
|
||
|
|
'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 applyBlockMigration
|
||
|
|
*
|
||
|
|
* Migrate a volume and/or snapshots to SBS (Scaleway Block Storage)
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ApplyBlockMigrationRequest $apply_block_migration_request apply_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['applyBlockMigration'] 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 applyBlockMigration($zone, $apply_block_migration_request, string $contentType = self::contentTypes['applyBlockMigration'][0])
|
||
|
|
{
|
||
|
|
$this->applyBlockMigrationWithHttpInfo($zone, $apply_block_migration_request, $contentType);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation applyBlockMigrationWithHttpInfo
|
||
|
|
*
|
||
|
|
* Migrate a volume and/or snapshots to SBS (Scaleway Block Storage)
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ApplyBlockMigrationRequest $apply_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['applyBlockMigration'] 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 applyBlockMigrationWithHttpInfo($zone, $apply_block_migration_request, string $contentType = self::contentTypes['applyBlockMigration'][0])
|
||
|
|
{
|
||
|
|
$request = $this->applyBlockMigrationRequest($zone, $apply_block_migration_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();
|
||
|
|
|
||
|
|
|
||
|
|
return [null, $statusCode, $response->getHeaders()];
|
||
|
|
|
||
|
|
} catch (ApiException $e) {
|
||
|
|
switch ($e->getCode()) {
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation applyBlockMigrationAsync
|
||
|
|
*
|
||
|
|
* Migrate a volume and/or snapshots to SBS (Scaleway Block Storage)
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ApplyBlockMigrationRequest $apply_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['applyBlockMigration'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function applyBlockMigrationAsync($zone, $apply_block_migration_request, string $contentType = self::contentTypes['applyBlockMigration'][0])
|
||
|
|
{
|
||
|
|
return $this->applyBlockMigrationAsyncWithHttpInfo($zone, $apply_block_migration_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation applyBlockMigrationAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Migrate a volume and/or snapshots to SBS (Scaleway Block Storage)
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ApplyBlockMigrationRequest $apply_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['applyBlockMigration'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function applyBlockMigrationAsyncWithHttpInfo($zone, $apply_block_migration_request, string $contentType = self::contentTypes['applyBlockMigration'][0])
|
||
|
|
{
|
||
|
|
$returnType = '';
|
||
|
|
$request = $this->applyBlockMigrationRequest($zone, $apply_block_migration_request, $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 'applyBlockMigration'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ApplyBlockMigrationRequest $apply_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['applyBlockMigration'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function applyBlockMigrationRequest($zone, $apply_block_migration_request, string $contentType = self::contentTypes['applyBlockMigration'][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 applyBlockMigration'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'apply_block_migration_request' is set
|
||
|
|
if ($apply_block_migration_request === null || (is_array($apply_block_migration_request) && count($apply_block_migration_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $apply_block_migration_request when calling applyBlockMigration'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/block-migration/apply';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
[],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (isset($apply_block_migration_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($apply_block_migration_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $apply_block_migration_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 createVolume
|
||
|
|
*
|
||
|
|
* Create a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateVolumeRequest $create_volume_request create_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createVolume'] 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\ScalewayInstanceV1CreateVolumeResponse
|
||
|
|
*/
|
||
|
|
public function createVolume($zone, $create_volume_request, string $contentType = self::contentTypes['createVolume'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->createVolumeWithHttpInfo($zone, $create_volume_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createVolumeWithHttpInfo
|
||
|
|
*
|
||
|
|
* Create a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateVolumeRequest $create_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createVolume'] 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\ScalewayInstanceV1CreateVolumeResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function createVolumeWithHttpInfo($zone, $create_volume_request, string $contentType = self::contentTypes['createVolume'][0])
|
||
|
|
{
|
||
|
|
$request = $this->createVolumeRequest($zone, $create_volume_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\ScalewayInstanceV1CreateVolumeResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1CreateVolumeResponse' !== '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\ScalewayInstanceV1CreateVolumeResponse', []),
|
||
|
|
$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\ScalewayInstanceV1CreateVolumeResponse';
|
||
|
|
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\ScalewayInstanceV1CreateVolumeResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createVolumeAsync
|
||
|
|
*
|
||
|
|
* Create a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateVolumeRequest $create_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function createVolumeAsync($zone, $create_volume_request, string $contentType = self::contentTypes['createVolume'][0])
|
||
|
|
{
|
||
|
|
return $this->createVolumeAsyncWithHttpInfo($zone, $create_volume_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createVolumeAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Create a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateVolumeRequest $create_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function createVolumeAsyncWithHttpInfo($zone, $create_volume_request, string $contentType = self::contentTypes['createVolume'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1CreateVolumeResponse';
|
||
|
|
$request = $this->createVolumeRequest($zone, $create_volume_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 'createVolume'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateVolumeRequest $create_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function createVolumeRequest($zone, $create_volume_request, string $contentType = self::contentTypes['createVolume'][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 createVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'create_volume_request' is set
|
||
|
|
if ($create_volume_request === null || (is_array($create_volume_request) && count($create_volume_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $create_volume_request when calling createVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/volumes';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (isset($create_volume_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_volume_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $create_volume_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 deleteVolume
|
||
|
|
*
|
||
|
|
* Delete a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to delete. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteVolume'] 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 deleteVolume($zone, $volume_id, string $contentType = self::contentTypes['deleteVolume'][0])
|
||
|
|
{
|
||
|
|
$this->deleteVolumeWithHttpInfo($zone, $volume_id, $contentType);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deleteVolumeWithHttpInfo
|
||
|
|
*
|
||
|
|
* Delete a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to delete. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteVolume'] 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 deleteVolumeWithHttpInfo($zone, $volume_id, string $contentType = self::contentTypes['deleteVolume'][0])
|
||
|
|
{
|
||
|
|
$request = $this->deleteVolumeRequest($zone, $volume_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 deleteVolumeAsync
|
||
|
|
*
|
||
|
|
* Delete a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to delete. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function deleteVolumeAsync($zone, $volume_id, string $contentType = self::contentTypes['deleteVolume'][0])
|
||
|
|
{
|
||
|
|
return $this->deleteVolumeAsyncWithHttpInfo($zone, $volume_id, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deleteVolumeAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Delete a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to delete. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function deleteVolumeAsyncWithHttpInfo($zone, $volume_id, string $contentType = self::contentTypes['deleteVolume'][0])
|
||
|
|
{
|
||
|
|
$returnType = '';
|
||
|
|
$request = $this->deleteVolumeRequest($zone, $volume_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 'deleteVolume'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to delete. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function deleteVolumeRequest($zone, $volume_id, string $contentType = self::contentTypes['deleteVolume'][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 deleteVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'volume_id' is set
|
||
|
|
if ($volume_id === null || (is_array($volume_id) && count($volume_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $volume_id when calling deleteVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/volumes/{volume_id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($volume_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'volume_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($volume_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 getVolume
|
||
|
|
*
|
||
|
|
* Get a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to get. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getVolume'] 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\ScalewayInstanceV1GetVolumeResponse
|
||
|
|
*/
|
||
|
|
public function getVolume($zone, $volume_id, string $contentType = self::contentTypes['getVolume'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->getVolumeWithHttpInfo($zone, $volume_id, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getVolumeWithHttpInfo
|
||
|
|
*
|
||
|
|
* Get a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to get. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getVolume'] 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\ScalewayInstanceV1GetVolumeResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function getVolumeWithHttpInfo($zone, $volume_id, string $contentType = self::contentTypes['getVolume'][0])
|
||
|
|
{
|
||
|
|
$request = $this->getVolumeRequest($zone, $volume_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\ScalewayInstanceV1GetVolumeResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1GetVolumeResponse' !== '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\ScalewayInstanceV1GetVolumeResponse', []),
|
||
|
|
$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\ScalewayInstanceV1GetVolumeResponse';
|
||
|
|
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\ScalewayInstanceV1GetVolumeResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getVolumeAsync
|
||
|
|
*
|
||
|
|
* Get a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to get. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function getVolumeAsync($zone, $volume_id, string $contentType = self::contentTypes['getVolume'][0])
|
||
|
|
{
|
||
|
|
return $this->getVolumeAsyncWithHttpInfo($zone, $volume_id, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getVolumeAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Get a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to get. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function getVolumeAsyncWithHttpInfo($zone, $volume_id, string $contentType = self::contentTypes['getVolume'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1GetVolumeResponse';
|
||
|
|
$request = $this->getVolumeRequest($zone, $volume_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 'getVolume'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume you want to get. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function getVolumeRequest($zone, $volume_id, string $contentType = self::contentTypes['getVolume'][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 getVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'volume_id' is set
|
||
|
|
if ($volume_id === null || (is_array($volume_id) && count($volume_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $volume_id when calling getVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/volumes/{volume_id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($volume_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'volume_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($volume_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 listVolumes
|
||
|
|
*
|
||
|
|
* List volumes
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string|null $volume_type Filter by volume type. (optional, default to 'l_ssd')
|
||
|
|
* @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|null $organization Filter volume by Organization ID. (optional)
|
||
|
|
* @param string|null $project Filter volume by Project ID. (optional)
|
||
|
|
* @param string|null $tags Filter volumes with these exact tags (to filter with several tags, use commas to separate them). (optional)
|
||
|
|
* @param string|null $name Filter volume by name (for eg. \"vol\" will return \"myvolume\" but not \"data\"). (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listVolumes'] 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\ScalewayInstanceV1ListVolumesResponse
|
||
|
|
*/
|
||
|
|
public function listVolumes($zone, $volume_type = 'l_ssd', $per_page = null, $page = null, $organization = null, $project = null, $tags = null, $name = null, string $contentType = self::contentTypes['listVolumes'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->listVolumesWithHttpInfo($zone, $volume_type, $per_page, $page, $organization, $project, $tags, $name, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listVolumesWithHttpInfo
|
||
|
|
*
|
||
|
|
* List volumes
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string|null $volume_type Filter by volume type. (optional, default to 'l_ssd')
|
||
|
|
* @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|null $organization Filter volume by Organization ID. (optional)
|
||
|
|
* @param string|null $project Filter volume by Project ID. (optional)
|
||
|
|
* @param string|null $tags Filter volumes with these exact tags (to filter with several tags, use commas to separate them). (optional)
|
||
|
|
* @param string|null $name Filter volume by name (for eg. \"vol\" will return \"myvolume\" but not \"data\"). (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listVolumes'] 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\ScalewayInstanceV1ListVolumesResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function listVolumesWithHttpInfo($zone, $volume_type = 'l_ssd', $per_page = null, $page = null, $organization = null, $project = null, $tags = null, $name = null, string $contentType = self::contentTypes['listVolumes'][0])
|
||
|
|
{
|
||
|
|
$request = $this->listVolumesRequest($zone, $volume_type, $per_page, $page, $organization, $project, $tags, $name, $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\ScalewayInstanceV1ListVolumesResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1ListVolumesResponse' !== '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\ScalewayInstanceV1ListVolumesResponse', []),
|
||
|
|
$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\ScalewayInstanceV1ListVolumesResponse';
|
||
|
|
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\ScalewayInstanceV1ListVolumesResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listVolumesAsync
|
||
|
|
*
|
||
|
|
* List volumes
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string|null $volume_type Filter by volume type. (optional, default to 'l_ssd')
|
||
|
|
* @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|null $organization Filter volume by Organization ID. (optional)
|
||
|
|
* @param string|null $project Filter volume by Project ID. (optional)
|
||
|
|
* @param string|null $tags Filter volumes with these exact tags (to filter with several tags, use commas to separate them). (optional)
|
||
|
|
* @param string|null $name Filter volume by name (for eg. \"vol\" will return \"myvolume\" but not \"data\"). (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listVolumes'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function listVolumesAsync($zone, $volume_type = 'l_ssd', $per_page = null, $page = null, $organization = null, $project = null, $tags = null, $name = null, string $contentType = self::contentTypes['listVolumes'][0])
|
||
|
|
{
|
||
|
|
return $this->listVolumesAsyncWithHttpInfo($zone, $volume_type, $per_page, $page, $organization, $project, $tags, $name, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listVolumesAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* List volumes
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string|null $volume_type Filter by volume type. (optional, default to 'l_ssd')
|
||
|
|
* @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|null $organization Filter volume by Organization ID. (optional)
|
||
|
|
* @param string|null $project Filter volume by Project ID. (optional)
|
||
|
|
* @param string|null $tags Filter volumes with these exact tags (to filter with several tags, use commas to separate them). (optional)
|
||
|
|
* @param string|null $name Filter volume by name (for eg. \"vol\" will return \"myvolume\" but not \"data\"). (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listVolumes'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function listVolumesAsyncWithHttpInfo($zone, $volume_type = 'l_ssd', $per_page = null, $page = null, $organization = null, $project = null, $tags = null, $name = null, string $contentType = self::contentTypes['listVolumes'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1ListVolumesResponse';
|
||
|
|
$request = $this->listVolumesRequest($zone, $volume_type, $per_page, $page, $organization, $project, $tags, $name, $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 'listVolumes'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string|null $volume_type Filter by volume type. (optional, default to 'l_ssd')
|
||
|
|
* @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|null $organization Filter volume by Organization ID. (optional)
|
||
|
|
* @param string|null $project Filter volume by Project ID. (optional)
|
||
|
|
* @param string|null $tags Filter volumes with these exact tags (to filter with several tags, use commas to separate them). (optional)
|
||
|
|
* @param string|null $name Filter volume by name (for eg. \"vol\" will return \"myvolume\" but not \"data\"). (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listVolumes'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function listVolumesRequest($zone, $volume_type = 'l_ssd', $per_page = null, $page = null, $organization = null, $project = null, $tags = null, $name = null, string $contentType = self::contentTypes['listVolumes'][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 listVolumes'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/volumes';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
// query params
|
||
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
||
|
|
$volume_type,
|
||
|
|
'volume_type', // 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
|
||
|
|
) ?? []);
|
||
|
|
// query params
|
||
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
||
|
|
$organization,
|
||
|
|
'organization', // param base name
|
||
|
|
'string', // openApiType
|
||
|
|
'form', // style
|
||
|
|
true, // explode
|
||
|
|
false // required
|
||
|
|
) ?? []);
|
||
|
|
// query params
|
||
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
||
|
|
$project,
|
||
|
|
'project', // param base name
|
||
|
|
'string', // openApiType
|
||
|
|
'form', // style
|
||
|
|
true, // explode
|
||
|
|
false // required
|
||
|
|
) ?? []);
|
||
|
|
// 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(
|
||
|
|
$name,
|
||
|
|
'name', // param base name
|
||
|
|
'string', // openApiType
|
||
|
|
'form', // style
|
||
|
|
true, // explode
|
||
|
|
false // required
|
||
|
|
) ?? []);
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$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 planBlockMigration
|
||
|
|
*
|
||
|
|
* Get a volume or snapshot's migration plan
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\PlanBlockMigrationRequest $plan_block_migration_request plan_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['planBlockMigration'] 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\ScalewayInstanceV1MigrationPlan
|
||
|
|
*/
|
||
|
|
public function planBlockMigration($zone, $plan_block_migration_request, string $contentType = self::contentTypes['planBlockMigration'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->planBlockMigrationWithHttpInfo($zone, $plan_block_migration_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation planBlockMigrationWithHttpInfo
|
||
|
|
*
|
||
|
|
* Get a volume or snapshot's migration plan
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\PlanBlockMigrationRequest $plan_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['planBlockMigration'] 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\ScalewayInstanceV1MigrationPlan, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function planBlockMigrationWithHttpInfo($zone, $plan_block_migration_request, string $contentType = self::contentTypes['planBlockMigration'][0])
|
||
|
|
{
|
||
|
|
$request = $this->planBlockMigrationRequest($zone, $plan_block_migration_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\ScalewayInstanceV1MigrationPlan' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1MigrationPlan' !== '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\ScalewayInstanceV1MigrationPlan', []),
|
||
|
|
$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\ScalewayInstanceV1MigrationPlan';
|
||
|
|
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\ScalewayInstanceV1MigrationPlan',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation planBlockMigrationAsync
|
||
|
|
*
|
||
|
|
* Get a volume or snapshot's migration plan
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\PlanBlockMigrationRequest $plan_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['planBlockMigration'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function planBlockMigrationAsync($zone, $plan_block_migration_request, string $contentType = self::contentTypes['planBlockMigration'][0])
|
||
|
|
{
|
||
|
|
return $this->planBlockMigrationAsyncWithHttpInfo($zone, $plan_block_migration_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation planBlockMigrationAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Get a volume or snapshot's migration plan
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\PlanBlockMigrationRequest $plan_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['planBlockMigration'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function planBlockMigrationAsyncWithHttpInfo($zone, $plan_block_migration_request, string $contentType = self::contentTypes['planBlockMigration'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1MigrationPlan';
|
||
|
|
$request = $this->planBlockMigrationRequest($zone, $plan_block_migration_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 'planBlockMigration'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\PlanBlockMigrationRequest $plan_block_migration_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['planBlockMigration'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function planBlockMigrationRequest($zone, $plan_block_migration_request, string $contentType = self::contentTypes['planBlockMigration'][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 planBlockMigration'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'plan_block_migration_request' is set
|
||
|
|
if ($plan_block_migration_request === null || (is_array($plan_block_migration_request) && count($plan_block_migration_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $plan_block_migration_request when calling planBlockMigration'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/block-migration/plan';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (isset($plan_block_migration_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($plan_block_migration_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $plan_block_migration_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 setVolume
|
||
|
|
*
|
||
|
|
* Update volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $id Unique ID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetVolumeRequest $set_volume_request set_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setVolume'] 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\ScalewayInstanceV1SetVolumeResponse
|
||
|
|
*/
|
||
|
|
public function setVolume($zone, $id, $set_volume_request, string $contentType = self::contentTypes['setVolume'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->setVolumeWithHttpInfo($zone, $id, $set_volume_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation setVolumeWithHttpInfo
|
||
|
|
*
|
||
|
|
* Update volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $id Unique ID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetVolumeRequest $set_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setVolume'] 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\ScalewayInstanceV1SetVolumeResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function setVolumeWithHttpInfo($zone, $id, $set_volume_request, string $contentType = self::contentTypes['setVolume'][0])
|
||
|
|
{
|
||
|
|
$request = $this->setVolumeRequest($zone, $id, $set_volume_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\ScalewayInstanceV1SetVolumeResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1SetVolumeResponse' !== '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\ScalewayInstanceV1SetVolumeResponse', []),
|
||
|
|
$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\ScalewayInstanceV1SetVolumeResponse';
|
||
|
|
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\ScalewayInstanceV1SetVolumeResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation setVolumeAsync
|
||
|
|
*
|
||
|
|
* Update volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $id Unique ID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetVolumeRequest $set_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function setVolumeAsync($zone, $id, $set_volume_request, string $contentType = self::contentTypes['setVolume'][0])
|
||
|
|
{
|
||
|
|
return $this->setVolumeAsyncWithHttpInfo($zone, $id, $set_volume_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation setVolumeAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Update volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $id Unique ID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetVolumeRequest $set_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function setVolumeAsyncWithHttpInfo($zone, $id, $set_volume_request, string $contentType = self::contentTypes['setVolume'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1SetVolumeResponse';
|
||
|
|
$request = $this->setVolumeRequest($zone, $id, $set_volume_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 'setVolume'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $id Unique ID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetVolumeRequest $set_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function setVolumeRequest($zone, $id, $set_volume_request, string $contentType = self::contentTypes['setVolume'][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 setVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'id' is set
|
||
|
|
if ($id === null || (is_array($id) && count($id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $id when calling setVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'set_volume_request' is set
|
||
|
|
if ($set_volume_request === null || (is_array($set_volume_request) && count($set_volume_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $set_volume_request when calling setVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/volumes/{id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (isset($set_volume_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($set_volume_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $set_volume_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(
|
||
|
|
'PUT',
|
||
|
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
||
|
|
$headers,
|
||
|
|
$httpBody
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updateVolume
|
||
|
|
*
|
||
|
|
* Update a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateVolumeRequest $update_volume_request update_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateVolume'] 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\ScalewayInstanceV1UpdateVolumeResponse
|
||
|
|
*/
|
||
|
|
public function updateVolume($zone, $volume_id, $update_volume_request, string $contentType = self::contentTypes['updateVolume'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->updateVolumeWithHttpInfo($zone, $volume_id, $update_volume_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updateVolumeWithHttpInfo
|
||
|
|
*
|
||
|
|
* Update a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateVolumeRequest $update_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateVolume'] 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\ScalewayInstanceV1UpdateVolumeResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function updateVolumeWithHttpInfo($zone, $volume_id, $update_volume_request, string $contentType = self::contentTypes['updateVolume'][0])
|
||
|
|
{
|
||
|
|
$request = $this->updateVolumeRequest($zone, $volume_id, $update_volume_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\ScalewayInstanceV1UpdateVolumeResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayInstanceV1UpdateVolumeResponse' !== '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\ScalewayInstanceV1UpdateVolumeResponse', []),
|
||
|
|
$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\ScalewayInstanceV1UpdateVolumeResponse';
|
||
|
|
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\ScalewayInstanceV1UpdateVolumeResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updateVolumeAsync
|
||
|
|
*
|
||
|
|
* Update a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateVolumeRequest $update_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function updateVolumeAsync($zone, $volume_id, $update_volume_request, string $contentType = self::contentTypes['updateVolume'][0])
|
||
|
|
{
|
||
|
|
return $this->updateVolumeAsyncWithHttpInfo($zone, $volume_id, $update_volume_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updateVolumeAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Update a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateVolumeRequest $update_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function updateVolumeAsyncWithHttpInfo($zone, $volume_id, $update_volume_request, string $contentType = self::contentTypes['updateVolume'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayInstanceV1UpdateVolumeResponse';
|
||
|
|
$request = $this->updateVolumeRequest($zone, $volume_id, $update_volume_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 'updateVolume'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $volume_id UUID of the volume. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateVolumeRequest $update_volume_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateVolume'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function updateVolumeRequest($zone, $volume_id, $update_volume_request, string $contentType = self::contentTypes['updateVolume'][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 updateVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'volume_id' is set
|
||
|
|
if ($volume_id === null || (is_array($volume_id) && count($volume_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $volume_id when calling updateVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'update_volume_request' is set
|
||
|
|
if ($update_volume_request === null || (is_array($update_volume_request) && count($update_volume_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $update_volume_request when calling updateVolume'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/instance/v1/zones/{zone}/volumes/{volume_id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($volume_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'volume_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($volume_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (isset($update_volume_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_volume_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $update_volume_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;
|
||
|
|
}
|
||
|
|
}
|