1847 lines
82 KiB
PHP
1847 lines
82 KiB
PHP
<?php
|
|
/**
|
|
* VolumeApi
|
|
* PHP version 7.4
|
|
*
|
|
* @category Class
|
|
* @package OpenAPI\Client
|
|
* @author OpenAPI Generator team
|
|
* @link https://openapi-generator.tech
|
|
*/
|
|
|
|
/**
|
|
* Block Storage API
|
|
*
|
|
* Scaleway Block Storage provides network-attached storage that can be plugged in and out of cloud products such as Instances like a virtual hard-drive. Block Storage devices are independent from the local storage of Instances, and the fact that they are accessed over a network connection makes it easy to move them between Instances in the same Availability Zone. (switchcolumn) <Message type=\"important\"> This page includes the API reference documentation for all Block Storage Low Latency offers. If you wish to use the Basic Block Storage offers, refer to the [Instances API documentation page](/api/instance/#path-volume-types-list-volume-types). </Message> (switchcolumn) ## Quickstart 1. Configure your environment variables. <Message type=\"note\"> This is an optional step that seeks to simplify your usage of the Block Storage 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>\" ``` <Message type=\"important\"> Make sure that the Availability Zone (AZ) is the same as the one of your Instance. Block volumes can only be attached to Instances in the same AZ. </Message> 2. Edit the POST request payload you will use to create your Block volume. Replace the parameters in the following example: ```json '{ \"project_id\": \"d8e65f2b-cce9-40b7-80fc-6a2902db6826\", \"name\": \"my-volume\", \"perf_iops\": \"5000\", \"tags\": [\"donnerstag\"], \"from_empty\": { \"size\": \"30000000000\"} }' ``` | Parameter | Description | | :----------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `project_id` | **REQUIRED** The ID of the Project you want to create your Block volume in. To find your Project ID you can **[list the projects](/api/account#path-projects-list-all-projects-of-an-organization)** or consult the **[Scaleway console](https://console.scaleway.com/project/settings)**. | | `name` | **REQUIRED** Name of the volume | | `perf_iops` | **REQUIRED** The maximum IO/s expected. This amount is a shared limit between write and read operations, it will be determined by your usage. You must specify either `5000`, or `15000`. | | `tags` | The list of tags `[\"tag1\", \"tag2\", ...]` that will be associated with the Database Instance. Tags can be appended to the query of the [List Database Instances](#path-database-instances-list-database-instances) call to show results for only the Database Instances using a specific tag. You can also combine tags to list Database Instances that posess all the appended tags. | | `from_empty` | When you create a brand new volume, as opposed to creating a volume from a snapshot, you must specifiy its size. | | `size` | Volume size. The value should be expressed in bytes. For example 30GB is expressed as 30000000000 | 3. Create a Block volume by running the following command. Make sure you include the payload you edited in the previous step. ```bash curl -X POST \\ -H \"X-Auth-Token: $SCW_SECRET_KEY\" \\ \"Content-Type: application/json\" \\ https://api.scaleway.com/block/v1alpha1/zone/$SCW_DEFAULT_ZONE/volumes \\ -d '{ \"project_id\": \"'\"$SCW_PROJECT_ID\"'\", \"name\": \"my-volume\", \"perf_iops\": \"5000\", \"tags\": [\"donnerstag\"], \"from_empty\": { \"size\": \"30000000000\"} }' ``` An output similar to the following displays : ```json '{ \"id\": \"e337a374-f19a-4b58-a45d-75076f75fbc5\", \"name\": \"my-volume\", \"type\": \"sbs_5k\", \"size\": 30000000000, \"project_id\": \"d8e65f2b-cce9-40b7-80fc-6a2902db6826\", \"created_at\": \"2023-09-28T15:48:59.105240Z\", \"updated_at\": \"2023-09-28T15:48:59.105240Z\", \"references\": [], \"parent_snapshot_id\": None, \"status\": \"creating\", \"tags\": [], \"specs\": {\"perf_iops\": 5000, \"class\": \"sbs\"}, \"zone\": \"fr-par-1\" }' ``` <Message type=\"note\"> Make sure to save the `id` of your volume, as it will be required in the next step. </Message> 4. Attach your volume to your Instance using the Instance API [Update an Instance](/api/instance/#path-instances-update-an-instance) call. <Message type=\"note\"> Make sure the Block volume is created and ready before attaching it to the Instance. </Message> <Message type=\"important\"> Make sure you include all your Instance's existing volumes in the payload, as the update can only be done to all or none of the volumes. The payload should include a minimum of one key (`\"0\"`) with a value equivalent to the setting parameters for the volume. Additional keys for additional volumes should increment by 1 each time. For example, the second volume is `\"1\"`, the third `\"2\"`, and so on. </Message> ```bash curl -X PATCH \\ -H \"X-Auth-Token: $SCW_SECRET_KEY\" \\ \"Content-Type: application/json\" \\ https://api.scaleway.com/instance/v1/zone/$SCW_DEFAULT_ZONE/servers/$INSTANCE_ID \\ -d '{ \"volumes\": { \"0\": { \"boot\": false, \"id\": \"571c8a17-ba68-4c1d-b137-bbd5bc7af104\", \"volume_type\": \"System volume\" } \"1\": { \"boot\": false, \"id\": \"e337a374-f19a-4b58-a45d-75076f75fbc5\", \"volume_type\": \"sbs_volume\" } }' ``` Your Block volume is ready to be used with your Instance. Refer to the [How to mount and use your Block volume](https://www.scaleway.com/en/docs/storage/block/how-to/mount-and-use-volume/) documentation page to do so. (switchcolumn) <Message type=\"requirement\"> To perform the following steps, you must first ensure that: - you have an account and are logged into the [Scaleway console](https://console.scaleway.com/organization) - you have created an [API key](https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/) and that the API key has sufficient [IAM permissions](https://www.scaleway.com/en/docs/identity-and-access-management/iam/reference-content/permission-sets/) to perform the actions described on this page. - you have [installed `curl`](https://curl.se/download.html) - you have [created an Instance](/instance/#path-instances-create-an-instance). </Message> (switchcolumn) ## Going further For further information and assitance for Scaleway Block Storage, check out the following resources: - [Basic Block Storage Documentation](https://www.scaleway.com/en/docs/storage/block/) - [#block channel in the Scaleway Slack Community](scaleway-community.slack.com) - [How to open a support ticket](https://www.scaleway.com/en/docs/console/my-account/how-to/open-a-support-ticket/).
|
|
*
|
|
* The version of the OpenAPI document: v1alpha1
|
|
* 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;
|
|
|
|
/**
|
|
* VolumeApi Class Doc Comment
|
|
*
|
|
* @category Class
|
|
* @package OpenAPI\Client
|
|
* @author OpenAPI Generator team
|
|
* @link https://openapi-generator.tech
|
|
*/
|
|
class VolumeApi
|
|
{
|
|
/**
|
|
* @var ClientInterface
|
|
*/
|
|
protected $client;
|
|
|
|
/**
|
|
* @var Configuration
|
|
*/
|
|
protected $config;
|
|
|
|
/**
|
|
* @var HeaderSelector
|
|
*/
|
|
protected $headerSelector;
|
|
|
|
/**
|
|
* @var int Host index
|
|
*/
|
|
protected $hostIndex;
|
|
|
|
/** @var string[] $contentTypes **/
|
|
public const contentTypes = [
|
|
'createVolume' => [
|
|
'application/json',
|
|
],
|
|
'deleteVolume' => [
|
|
'application/json',
|
|
],
|
|
'getVolume' => [
|
|
'application/json',
|
|
],
|
|
'listVolumes' => [
|
|
'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 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\ScalewayBlockV1alpha1Volume
|
|
*/
|
|
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\ScalewayBlockV1alpha1Volume, 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 200:
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Volume' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Volume' !== '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\ScalewayBlockV1alpha1Volume', []),
|
|
$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\ScalewayBlockV1alpha1Volume';
|
|
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\ScalewayBlockV1alpha1Volume',
|
|
$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\ScalewayBlockV1alpha1Volume';
|
|
$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 = '/block/v1alpha1/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 detached volume
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $volume_id UUID of the volume. (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 detached volume
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $volume_id UUID of the volume. (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 detached volume
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $volume_id UUID of the volume. (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 detached volume
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $volume_id UUID of the volume. (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. (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 = '/block/v1alpha1/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. (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\ScalewayBlockV1alpha1Volume
|
|
*/
|
|
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. (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\ScalewayBlockV1alpha1Volume, 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\ScalewayBlockV1alpha1Volume' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Volume' !== '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\ScalewayBlockV1alpha1Volume', []),
|
|
$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\ScalewayBlockV1alpha1Volume';
|
|
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\ScalewayBlockV1alpha1Volume',
|
|
$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. (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. (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\ScalewayBlockV1alpha1Volume';
|
|
$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. (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 = '/block/v1alpha1/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 $order_by Criteria to use when ordering the list. (optional, default to 'created_at_asc')
|
|
* @param string|null $project_id Filter by Project ID. (optional)
|
|
* @param string|null $organization_id Filter by Organization ID. (optional)
|
|
* @param int|null $page Page number. (optional)
|
|
* @param int|null $page_size Page size, defines how many entries are returned in one page, must be lower or equal to 100. (optional, default to 50)
|
|
* @param string|null $name Filter the return volumes by their names. (optional)
|
|
* @param string|null $product_resource_id Filter by a product resource ID linked to this volume (such as an Instance ID). (optional)
|
|
* @param string[]|null $tags Filter by tags. Only volumes with one or more matching tags will be returned. (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\ScalewayBlockV1alpha1ListVolumesResponse
|
|
*/
|
|
public function listVolumes($zone, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $name = null, $product_resource_id = null, $tags = null, string $contentType = self::contentTypes['listVolumes'][0])
|
|
{
|
|
list($response) = $this->listVolumesWithHttpInfo($zone, $order_by, $project_id, $organization_id, $page, $page_size, $name, $product_resource_id, $tags, $contentType);
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Operation listVolumesWithHttpInfo
|
|
*
|
|
* List volumes
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string|null $order_by Criteria to use when ordering the list. (optional, default to 'created_at_asc')
|
|
* @param string|null $project_id Filter by Project ID. (optional)
|
|
* @param string|null $organization_id Filter by Organization ID. (optional)
|
|
* @param int|null $page Page number. (optional)
|
|
* @param int|null $page_size Page size, defines how many entries are returned in one page, must be lower or equal to 100. (optional, default to 50)
|
|
* @param string|null $name Filter the return volumes by their names. (optional)
|
|
* @param string|null $product_resource_id Filter by a product resource ID linked to this volume (such as an Instance ID). (optional)
|
|
* @param string[]|null $tags Filter by tags. Only volumes with one or more matching tags will be returned. (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\ScalewayBlockV1alpha1ListVolumesResponse, HTTP status code, HTTP response headers (array of strings)
|
|
*/
|
|
public function listVolumesWithHttpInfo($zone, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $name = null, $product_resource_id = null, $tags = null, string $contentType = self::contentTypes['listVolumes'][0])
|
|
{
|
|
$request = $this->listVolumesRequest($zone, $order_by, $project_id, $organization_id, $page, $page_size, $name, $product_resource_id, $tags, $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\ScalewayBlockV1alpha1ListVolumesResponse' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1ListVolumesResponse' !== '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\ScalewayBlockV1alpha1ListVolumesResponse', []),
|
|
$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\ScalewayBlockV1alpha1ListVolumesResponse';
|
|
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\ScalewayBlockV1alpha1ListVolumesResponse',
|
|
$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 $order_by Criteria to use when ordering the list. (optional, default to 'created_at_asc')
|
|
* @param string|null $project_id Filter by Project ID. (optional)
|
|
* @param string|null $organization_id Filter by Organization ID. (optional)
|
|
* @param int|null $page Page number. (optional)
|
|
* @param int|null $page_size Page size, defines how many entries are returned in one page, must be lower or equal to 100. (optional, default to 50)
|
|
* @param string|null $name Filter the return volumes by their names. (optional)
|
|
* @param string|null $product_resource_id Filter by a product resource ID linked to this volume (such as an Instance ID). (optional)
|
|
* @param string[]|null $tags Filter by tags. Only volumes with one or more matching tags will be returned. (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, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $name = null, $product_resource_id = null, $tags = null, string $contentType = self::contentTypes['listVolumes'][0])
|
|
{
|
|
return $this->listVolumesAsyncWithHttpInfo($zone, $order_by, $project_id, $organization_id, $page, $page_size, $name, $product_resource_id, $tags, $contentType)
|
|
->then(
|
|
function ($response) {
|
|
return $response[0];
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation listVolumesAsyncWithHttpInfo
|
|
*
|
|
* List volumes
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string|null $order_by Criteria to use when ordering the list. (optional, default to 'created_at_asc')
|
|
* @param string|null $project_id Filter by Project ID. (optional)
|
|
* @param string|null $organization_id Filter by Organization ID. (optional)
|
|
* @param int|null $page Page number. (optional)
|
|
* @param int|null $page_size Page size, defines how many entries are returned in one page, must be lower or equal to 100. (optional, default to 50)
|
|
* @param string|null $name Filter the return volumes by their names. (optional)
|
|
* @param string|null $product_resource_id Filter by a product resource ID linked to this volume (such as an Instance ID). (optional)
|
|
* @param string[]|null $tags Filter by tags. Only volumes with one or more matching tags will be returned. (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, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $name = null, $product_resource_id = null, $tags = null, string $contentType = self::contentTypes['listVolumes'][0])
|
|
{
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayBlockV1alpha1ListVolumesResponse';
|
|
$request = $this->listVolumesRequest($zone, $order_by, $project_id, $organization_id, $page, $page_size, $name, $product_resource_id, $tags, $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 $order_by Criteria to use when ordering the list. (optional, default to 'created_at_asc')
|
|
* @param string|null $project_id Filter by Project ID. (optional)
|
|
* @param string|null $organization_id Filter by Organization ID. (optional)
|
|
* @param int|null $page Page number. (optional)
|
|
* @param int|null $page_size Page size, defines how many entries are returned in one page, must be lower or equal to 100. (optional, default to 50)
|
|
* @param string|null $name Filter the return volumes by their names. (optional)
|
|
* @param string|null $product_resource_id Filter by a product resource ID linked to this volume (such as an Instance ID). (optional)
|
|
* @param string[]|null $tags Filter by tags. Only volumes with one or more matching tags will be returned. (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, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $name = null, $product_resource_id = null, $tags = 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 = '/block/v1alpha1/zones/{zone}/volumes';
|
|
$formParams = [];
|
|
$queryParams = [];
|
|
$headerParams = [];
|
|
$httpBody = '';
|
|
$multipart = false;
|
|
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$order_by,
|
|
'order_by', // param base name
|
|
'string', // openApiType
|
|
'form', // style
|
|
true, // explode
|
|
false // required
|
|
) ?? []);
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$project_id,
|
|
'project_id', // param base name
|
|
'string', // openApiType
|
|
'form', // style
|
|
true, // explode
|
|
false // required
|
|
) ?? []);
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$organization_id,
|
|
'organization_id', // param base name
|
|
'string', // 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(
|
|
$page_size,
|
|
'page_size', // param base name
|
|
'integer', // 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
|
|
) ?? []);
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$product_resource_id,
|
|
'product_resource_id', // param base name
|
|
'string', // openApiType
|
|
'form', // style
|
|
true, // explode
|
|
false // required
|
|
) ?? []);
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$tags,
|
|
'tags', // param base name
|
|
'array', // 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 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\ScalewayBlockV1alpha1Volume
|
|
*/
|
|
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\ScalewayBlockV1alpha1Volume, 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\ScalewayBlockV1alpha1Volume' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Volume' !== '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\ScalewayBlockV1alpha1Volume', []),
|
|
$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\ScalewayBlockV1alpha1Volume';
|
|
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\ScalewayBlockV1alpha1Volume',
|
|
$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\ScalewayBlockV1alpha1Volume';
|
|
$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 = '/block/v1alpha1/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;
|
|
}
|
|
}
|