2877 lines
127 KiB
PHP
2877 lines
127 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* SnapshotApi
|
||
|
|
* 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 th
|
||
|
|
*
|
||
|
|
* 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;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* SnapshotApi Class Doc Comment
|
||
|
|
*
|
||
|
|
* @category Class
|
||
|
|
* @package OpenAPI\Client
|
||
|
|
* @author OpenAPI Generator team
|
||
|
|
* @link https://openapi-generator.tech
|
||
|
|
*/
|
||
|
|
class SnapshotApi
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @var ClientInterface
|
||
|
|
*/
|
||
|
|
protected $client;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var Configuration
|
||
|
|
*/
|
||
|
|
protected $config;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var HeaderSelector
|
||
|
|
*/
|
||
|
|
protected $headerSelector;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var int Host index
|
||
|
|
*/
|
||
|
|
protected $hostIndex;
|
||
|
|
|
||
|
|
/** @var string[] $contentTypes **/
|
||
|
|
public const contentTypes = [
|
||
|
|
'createSnapshot' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'deleteSnapshot' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'exportSnapshotToObjectStorage' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'getSnapshot' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'importSnapshotFromObjectStorage' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'importSnapshotFromS3' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'listSnapshots' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'updateSnapshot' => [
|
||
|
|
'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 createSnapshot
|
||
|
|
*
|
||
|
|
* Create a snapshot of a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateSnapshotRequest $create_snapshot_request create_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createSnapshot'] 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\ScalewayBlockV1alpha1Snapshot
|
||
|
|
*/
|
||
|
|
public function createSnapshot($zone, $create_snapshot_request, string $contentType = self::contentTypes['createSnapshot'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->createSnapshotWithHttpInfo($zone, $create_snapshot_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createSnapshotWithHttpInfo
|
||
|
|
*
|
||
|
|
* Create a snapshot of a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateSnapshotRequest $create_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createSnapshot'] 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\ScalewayBlockV1alpha1Snapshot, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function createSnapshotWithHttpInfo($zone, $create_snapshot_request, string $contentType = self::contentTypes['createSnapshot'][0])
|
||
|
|
{
|
||
|
|
$request = $this->createSnapshotRequest($zone, $create_snapshot_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\ScalewayBlockV1alpha1Snapshot' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot' !== '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\ScalewayBlockV1alpha1Snapshot', []),
|
||
|
|
$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\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
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\ScalewayBlockV1alpha1Snapshot',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createSnapshotAsync
|
||
|
|
*
|
||
|
|
* Create a snapshot of a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateSnapshotRequest $create_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function createSnapshotAsync($zone, $create_snapshot_request, string $contentType = self::contentTypes['createSnapshot'][0])
|
||
|
|
{
|
||
|
|
return $this->createSnapshotAsyncWithHttpInfo($zone, $create_snapshot_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation createSnapshotAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Create a snapshot of a volume
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateSnapshotRequest $create_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function createSnapshotAsyncWithHttpInfo($zone, $create_snapshot_request, string $contentType = self::contentTypes['createSnapshot'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
$request = $this->createSnapshotRequest($zone, $create_snapshot_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 'createSnapshot'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\CreateSnapshotRequest $create_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function createSnapshotRequest($zone, $create_snapshot_request, string $contentType = self::contentTypes['createSnapshot'][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 createSnapshot'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'create_snapshot_request' is set
|
||
|
|
if ($create_snapshot_request === null || (is_array($create_snapshot_request) && count($create_snapshot_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $create_snapshot_request when calling createSnapshot'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/block/v1alpha1/zones/{zone}/snapshots';
|
||
|
|
$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_snapshot_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_snapshot_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $create_snapshot_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 deleteSnapshot
|
||
|
|
*
|
||
|
|
* Delete a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteSnapshot'] 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 deleteSnapshot($zone, $snapshot_id, string $contentType = self::contentTypes['deleteSnapshot'][0])
|
||
|
|
{
|
||
|
|
$this->deleteSnapshotWithHttpInfo($zone, $snapshot_id, $contentType);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deleteSnapshotWithHttpInfo
|
||
|
|
*
|
||
|
|
* Delete a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteSnapshot'] 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 deleteSnapshotWithHttpInfo($zone, $snapshot_id, string $contentType = self::contentTypes['deleteSnapshot'][0])
|
||
|
|
{
|
||
|
|
$request = $this->deleteSnapshotRequest($zone, $snapshot_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 deleteSnapshotAsync
|
||
|
|
*
|
||
|
|
* Delete a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function deleteSnapshotAsync($zone, $snapshot_id, string $contentType = self::contentTypes['deleteSnapshot'][0])
|
||
|
|
{
|
||
|
|
return $this->deleteSnapshotAsyncWithHttpInfo($zone, $snapshot_id, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deleteSnapshotAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Delete a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function deleteSnapshotAsyncWithHttpInfo($zone, $snapshot_id, string $contentType = self::contentTypes['deleteSnapshot'][0])
|
||
|
|
{
|
||
|
|
$returnType = '';
|
||
|
|
$request = $this->deleteSnapshotRequest($zone, $snapshot_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 'deleteSnapshot'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function deleteSnapshotRequest($zone, $snapshot_id, string $contentType = self::contentTypes['deleteSnapshot'][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 deleteSnapshot'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'snapshot_id' is set
|
||
|
|
if ($snapshot_id === null || (is_array($snapshot_id) && count($snapshot_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $snapshot_id when calling deleteSnapshot'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/block/v1alpha1/zones/{zone}/snapshots/{snapshot_id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($snapshot_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'snapshot_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($snapshot_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 exportSnapshotToObjectStorage
|
||
|
|
*
|
||
|
|
* Export a snapshot to a Scaleway Object Storage bucket
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (UUID format) (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ExportSnapshotToObjectStorageRequest $export_snapshot_to_object_storage_request export_snapshot_to_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['exportSnapshotToObjectStorage'] 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\ScalewayBlockV1alpha1Snapshot
|
||
|
|
*/
|
||
|
|
public function exportSnapshotToObjectStorage($zone, $snapshot_id, $export_snapshot_to_object_storage_request, string $contentType = self::contentTypes['exportSnapshotToObjectStorage'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->exportSnapshotToObjectStorageWithHttpInfo($zone, $snapshot_id, $export_snapshot_to_object_storage_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation exportSnapshotToObjectStorageWithHttpInfo
|
||
|
|
*
|
||
|
|
* Export a snapshot to a Scaleway Object Storage bucket
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (UUID format) (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ExportSnapshotToObjectStorageRequest $export_snapshot_to_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['exportSnapshotToObjectStorage'] 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\ScalewayBlockV1alpha1Snapshot, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function exportSnapshotToObjectStorageWithHttpInfo($zone, $snapshot_id, $export_snapshot_to_object_storage_request, string $contentType = self::contentTypes['exportSnapshotToObjectStorage'][0])
|
||
|
|
{
|
||
|
|
$request = $this->exportSnapshotToObjectStorageRequest($zone, $snapshot_id, $export_snapshot_to_object_storage_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\ScalewayBlockV1alpha1Snapshot' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot' !== '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\ScalewayBlockV1alpha1Snapshot', []),
|
||
|
|
$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\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
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\ScalewayBlockV1alpha1Snapshot',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation exportSnapshotToObjectStorageAsync
|
||
|
|
*
|
||
|
|
* Export a snapshot to a Scaleway Object Storage bucket
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (UUID format) (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ExportSnapshotToObjectStorageRequest $export_snapshot_to_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['exportSnapshotToObjectStorage'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function exportSnapshotToObjectStorageAsync($zone, $snapshot_id, $export_snapshot_to_object_storage_request, string $contentType = self::contentTypes['exportSnapshotToObjectStorage'][0])
|
||
|
|
{
|
||
|
|
return $this->exportSnapshotToObjectStorageAsyncWithHttpInfo($zone, $snapshot_id, $export_snapshot_to_object_storage_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation exportSnapshotToObjectStorageAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Export a snapshot to a Scaleway Object Storage bucket
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (UUID format) (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ExportSnapshotToObjectStorageRequest $export_snapshot_to_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['exportSnapshotToObjectStorage'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function exportSnapshotToObjectStorageAsyncWithHttpInfo($zone, $snapshot_id, $export_snapshot_to_object_storage_request, string $contentType = self::contentTypes['exportSnapshotToObjectStorage'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
$request = $this->exportSnapshotToObjectStorageRequest($zone, $snapshot_id, $export_snapshot_to_object_storage_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 'exportSnapshotToObjectStorage'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (UUID format) (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ExportSnapshotToObjectStorageRequest $export_snapshot_to_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['exportSnapshotToObjectStorage'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function exportSnapshotToObjectStorageRequest($zone, $snapshot_id, $export_snapshot_to_object_storage_request, string $contentType = self::contentTypes['exportSnapshotToObjectStorage'][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 exportSnapshotToObjectStorage'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'snapshot_id' is set
|
||
|
|
if ($snapshot_id === null || (is_array($snapshot_id) && count($snapshot_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $snapshot_id when calling exportSnapshotToObjectStorage'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'export_snapshot_to_object_storage_request' is set
|
||
|
|
if ($export_snapshot_to_object_storage_request === null || (is_array($export_snapshot_to_object_storage_request) && count($export_snapshot_to_object_storage_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $export_snapshot_to_object_storage_request when calling exportSnapshotToObjectStorage'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/block/v1alpha1/zones/{zone}/snapshots/{snapshot_id}/export-to-object-storage';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($snapshot_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'snapshot_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($snapshot_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (isset($export_snapshot_to_object_storage_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($export_snapshot_to_object_storage_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $export_snapshot_to_object_storage_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 getSnapshot
|
||
|
|
*
|
||
|
|
* Get a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSnapshot'] 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\ScalewayBlockV1alpha1Snapshot
|
||
|
|
*/
|
||
|
|
public function getSnapshot($zone, $snapshot_id, string $contentType = self::contentTypes['getSnapshot'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->getSnapshotWithHttpInfo($zone, $snapshot_id, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getSnapshotWithHttpInfo
|
||
|
|
*
|
||
|
|
* Get a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSnapshot'] 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\ScalewayBlockV1alpha1Snapshot, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function getSnapshotWithHttpInfo($zone, $snapshot_id, string $contentType = self::contentTypes['getSnapshot'][0])
|
||
|
|
{
|
||
|
|
$request = $this->getSnapshotRequest($zone, $snapshot_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\ScalewayBlockV1alpha1Snapshot' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot' !== '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\ScalewayBlockV1alpha1Snapshot', []),
|
||
|
|
$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\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
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\ScalewayBlockV1alpha1Snapshot',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getSnapshotAsync
|
||
|
|
*
|
||
|
|
* Get a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function getSnapshotAsync($zone, $snapshot_id, string $contentType = self::contentTypes['getSnapshot'][0])
|
||
|
|
{
|
||
|
|
return $this->getSnapshotAsyncWithHttpInfo($zone, $snapshot_id, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation getSnapshotAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Get a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function getSnapshotAsyncWithHttpInfo($zone, $snapshot_id, string $contentType = self::contentTypes['getSnapshot'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
$request = $this->getSnapshotRequest($zone, $snapshot_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 'getSnapshot'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function getSnapshotRequest($zone, $snapshot_id, string $contentType = self::contentTypes['getSnapshot'][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 getSnapshot'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'snapshot_id' is set
|
||
|
|
if ($snapshot_id === null || (is_array($snapshot_id) && count($snapshot_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $snapshot_id when calling getSnapshot'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/block/v1alpha1/zones/{zone}/snapshots/{snapshot_id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($snapshot_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'snapshot_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($snapshot_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 importSnapshotFromObjectStorage
|
||
|
|
*
|
||
|
|
* Import a snapshot from a Scaleway Object Storage bucket
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromObjectStorage'] 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\ScalewayBlockV1alpha1Snapshot
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromObjectStorage($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromObjectStorage'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->importSnapshotFromObjectStorageWithHttpInfo($zone, $import_snapshot_from_object_storage_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation importSnapshotFromObjectStorageWithHttpInfo
|
||
|
|
*
|
||
|
|
* Import a snapshot from a Scaleway Object Storage bucket
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromObjectStorage'] 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\ScalewayBlockV1alpha1Snapshot, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromObjectStorageWithHttpInfo($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromObjectStorage'][0])
|
||
|
|
{
|
||
|
|
$request = $this->importSnapshotFromObjectStorageRequest($zone, $import_snapshot_from_object_storage_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\ScalewayBlockV1alpha1Snapshot' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot' !== '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\ScalewayBlockV1alpha1Snapshot', []),
|
||
|
|
$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\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
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\ScalewayBlockV1alpha1Snapshot',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation importSnapshotFromObjectStorageAsync
|
||
|
|
*
|
||
|
|
* Import a snapshot from a Scaleway Object Storage bucket
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromObjectStorage'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromObjectStorageAsync($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromObjectStorage'][0])
|
||
|
|
{
|
||
|
|
return $this->importSnapshotFromObjectStorageAsyncWithHttpInfo($zone, $import_snapshot_from_object_storage_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation importSnapshotFromObjectStorageAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Import a snapshot from a Scaleway Object Storage bucket
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromObjectStorage'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromObjectStorageAsyncWithHttpInfo($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromObjectStorage'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
$request = $this->importSnapshotFromObjectStorageRequest($zone, $import_snapshot_from_object_storage_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 'importSnapshotFromObjectStorage'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromObjectStorage'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromObjectStorageRequest($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromObjectStorage'][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 importSnapshotFromObjectStorage'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'import_snapshot_from_object_storage_request' is set
|
||
|
|
if ($import_snapshot_from_object_storage_request === null || (is_array($import_snapshot_from_object_storage_request) && count($import_snapshot_from_object_storage_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $import_snapshot_from_object_storage_request when calling importSnapshotFromObjectStorage'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/block/v1alpha1/zones/{zone}/snapshots/import-from-object-storage';
|
||
|
|
$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($import_snapshot_from_object_storage_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($import_snapshot_from_object_storage_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $import_snapshot_from_object_storage_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 importSnapshotFromS3
|
||
|
|
*
|
||
|
|
* (Deprecated in favor of `ImportSnapshotFromObjectStorage`)
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromS3'] 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\ScalewayBlockV1alpha1Snapshot
|
||
|
|
* @deprecated
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromS3($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromS3'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->importSnapshotFromS3WithHttpInfo($zone, $import_snapshot_from_object_storage_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation importSnapshotFromS3WithHttpInfo
|
||
|
|
*
|
||
|
|
* (Deprecated in favor of `ImportSnapshotFromObjectStorage`)
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromS3'] 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\ScalewayBlockV1alpha1Snapshot, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
* @deprecated
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromS3WithHttpInfo($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromS3'][0])
|
||
|
|
{
|
||
|
|
$request = $this->importSnapshotFromS3Request($zone, $import_snapshot_from_object_storage_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\ScalewayBlockV1alpha1Snapshot' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot' !== '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\ScalewayBlockV1alpha1Snapshot', []),
|
||
|
|
$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\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
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\ScalewayBlockV1alpha1Snapshot',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation importSnapshotFromS3Async
|
||
|
|
*
|
||
|
|
* (Deprecated in favor of `ImportSnapshotFromObjectStorage`)
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromS3'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
* @deprecated
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromS3Async($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromS3'][0])
|
||
|
|
{
|
||
|
|
return $this->importSnapshotFromS3AsyncWithHttpInfo($zone, $import_snapshot_from_object_storage_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation importSnapshotFromS3AsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* (Deprecated in favor of `ImportSnapshotFromObjectStorage`)
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromS3'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
* @deprecated
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromS3AsyncWithHttpInfo($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromS3'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
$request = $this->importSnapshotFromS3Request($zone, $import_snapshot_from_object_storage_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 'importSnapshotFromS3'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param \OpenAPI\Client\Model\ImportSnapshotFromObjectStorageRequest $import_snapshot_from_object_storage_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['importSnapshotFromS3'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
* @deprecated
|
||
|
|
*/
|
||
|
|
public function importSnapshotFromS3Request($zone, $import_snapshot_from_object_storage_request, string $contentType = self::contentTypes['importSnapshotFromS3'][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 importSnapshotFromS3'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'import_snapshot_from_object_storage_request' is set
|
||
|
|
if ($import_snapshot_from_object_storage_request === null || (is_array($import_snapshot_from_object_storage_request) && count($import_snapshot_from_object_storage_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $import_snapshot_from_object_storage_request when calling importSnapshotFromS3'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/block/v1alpha1/zones/{zone}/snapshots/import-from-s3';
|
||
|
|
$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($import_snapshot_from_object_storage_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($import_snapshot_from_object_storage_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $import_snapshot_from_object_storage_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 listSnapshots
|
||
|
|
*
|
||
|
|
* List all snapshots
|
||
|
|
*
|
||
|
|
* @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 $volume_id Filter snapshots by the ID of the original volume. (optional)
|
||
|
|
* @param string|null $name Filter snapshots by their names. (optional)
|
||
|
|
* @param string[]|null $tags Filter by tags. Only snapshots with one or more matching tags will be returned. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listSnapshots'] 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\ScalewayBlockV1alpha1ListSnapshotsResponse
|
||
|
|
*/
|
||
|
|
public function listSnapshots($zone, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $volume_id = null, $name = null, $tags = null, string $contentType = self::contentTypes['listSnapshots'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->listSnapshotsWithHttpInfo($zone, $order_by, $project_id, $organization_id, $page, $page_size, $volume_id, $name, $tags, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listSnapshotsWithHttpInfo
|
||
|
|
*
|
||
|
|
* List all snapshots
|
||
|
|
*
|
||
|
|
* @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 $volume_id Filter snapshots by the ID of the original volume. (optional)
|
||
|
|
* @param string|null $name Filter snapshots by their names. (optional)
|
||
|
|
* @param string[]|null $tags Filter by tags. Only snapshots with one or more matching tags will be returned. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listSnapshots'] 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\ScalewayBlockV1alpha1ListSnapshotsResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function listSnapshotsWithHttpInfo($zone, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $volume_id = null, $name = null, $tags = null, string $contentType = self::contentTypes['listSnapshots'][0])
|
||
|
|
{
|
||
|
|
$request = $this->listSnapshotsRequest($zone, $order_by, $project_id, $organization_id, $page, $page_size, $volume_id, $name, $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\ScalewayBlockV1alpha1ListSnapshotsResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1ListSnapshotsResponse' !== '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\ScalewayBlockV1alpha1ListSnapshotsResponse', []),
|
||
|
|
$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\ScalewayBlockV1alpha1ListSnapshotsResponse';
|
||
|
|
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\ScalewayBlockV1alpha1ListSnapshotsResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listSnapshotsAsync
|
||
|
|
*
|
||
|
|
* List all snapshots
|
||
|
|
*
|
||
|
|
* @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 $volume_id Filter snapshots by the ID of the original volume. (optional)
|
||
|
|
* @param string|null $name Filter snapshots by their names. (optional)
|
||
|
|
* @param string[]|null $tags Filter by tags. Only snapshots with one or more matching tags will be returned. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listSnapshots'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function listSnapshotsAsync($zone, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $volume_id = null, $name = null, $tags = null, string $contentType = self::contentTypes['listSnapshots'][0])
|
||
|
|
{
|
||
|
|
return $this->listSnapshotsAsyncWithHttpInfo($zone, $order_by, $project_id, $organization_id, $page, $page_size, $volume_id, $name, $tags, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation listSnapshotsAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* List all snapshots
|
||
|
|
*
|
||
|
|
* @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 $volume_id Filter snapshots by the ID of the original volume. (optional)
|
||
|
|
* @param string|null $name Filter snapshots by their names. (optional)
|
||
|
|
* @param string[]|null $tags Filter by tags. Only snapshots with one or more matching tags will be returned. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listSnapshots'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function listSnapshotsAsyncWithHttpInfo($zone, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $volume_id = null, $name = null, $tags = null, string $contentType = self::contentTypes['listSnapshots'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayBlockV1alpha1ListSnapshotsResponse';
|
||
|
|
$request = $this->listSnapshotsRequest($zone, $order_by, $project_id, $organization_id, $page, $page_size, $volume_id, $name, $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 'listSnapshots'
|
||
|
|
*
|
||
|
|
* @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 $volume_id Filter snapshots by the ID of the original volume. (optional)
|
||
|
|
* @param string|null $name Filter snapshots by their names. (optional)
|
||
|
|
* @param string[]|null $tags Filter by tags. Only snapshots with one or more matching tags will be returned. (optional)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listSnapshots'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function listSnapshotsRequest($zone, $order_by = 'created_at_asc', $project_id = null, $organization_id = null, $page = null, $page_size = 50, $volume_id = null, $name = null, $tags = null, string $contentType = self::contentTypes['listSnapshots'][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 listSnapshots'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/block/v1alpha1/zones/{zone}/snapshots';
|
||
|
|
$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(
|
||
|
|
$volume_id,
|
||
|
|
'volume_id', // 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
|
||
|
|
) ?? []);
|
||
|
|
// 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 updateSnapshot
|
||
|
|
*
|
||
|
|
* Update a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateSnapshotRequest $update_snapshot_request update_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateSnapshot'] 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\ScalewayBlockV1alpha1Snapshot
|
||
|
|
*/
|
||
|
|
public function updateSnapshot($zone, $snapshot_id, $update_snapshot_request, string $contentType = self::contentTypes['updateSnapshot'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->updateSnapshotWithHttpInfo($zone, $snapshot_id, $update_snapshot_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updateSnapshotWithHttpInfo
|
||
|
|
*
|
||
|
|
* Update a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateSnapshotRequest $update_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateSnapshot'] 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\ScalewayBlockV1alpha1Snapshot, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function updateSnapshotWithHttpInfo($zone, $snapshot_id, $update_snapshot_request, string $contentType = self::contentTypes['updateSnapshot'][0])
|
||
|
|
{
|
||
|
|
$request = $this->updateSnapshotRequest($zone, $snapshot_id, $update_snapshot_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\ScalewayBlockV1alpha1Snapshot' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot' !== '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\ScalewayBlockV1alpha1Snapshot', []),
|
||
|
|
$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\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
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\ScalewayBlockV1alpha1Snapshot',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updateSnapshotAsync
|
||
|
|
*
|
||
|
|
* Update a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateSnapshotRequest $update_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function updateSnapshotAsync($zone, $snapshot_id, $update_snapshot_request, string $contentType = self::contentTypes['updateSnapshot'][0])
|
||
|
|
{
|
||
|
|
return $this->updateSnapshotAsyncWithHttpInfo($zone, $snapshot_id, $update_snapshot_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation updateSnapshotAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Update a snapshot
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateSnapshotRequest $update_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function updateSnapshotAsyncWithHttpInfo($zone, $snapshot_id, $update_snapshot_request, string $contentType = self::contentTypes['updateSnapshot'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayBlockV1alpha1Snapshot';
|
||
|
|
$request = $this->updateSnapshotRequest($zone, $snapshot_id, $update_snapshot_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 'updateSnapshot'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $snapshot_id UUID of the snapshot. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\UpdateSnapshotRequest $update_snapshot_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateSnapshot'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function updateSnapshotRequest($zone, $snapshot_id, $update_snapshot_request, string $contentType = self::contentTypes['updateSnapshot'][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 updateSnapshot'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'snapshot_id' is set
|
||
|
|
if ($snapshot_id === null || (is_array($snapshot_id) && count($snapshot_id) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $snapshot_id when calling updateSnapshot'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'update_snapshot_request' is set
|
||
|
|
if ($update_snapshot_request === null || (is_array($update_snapshot_request) && count($update_snapshot_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $update_snapshot_request when calling updateSnapshot'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/block/v1alpha1/zones/{zone}/snapshots/{snapshot_id}';
|
||
|
|
$formParams = [];
|
||
|
|
$queryParams = [];
|
||
|
|
$headerParams = [];
|
||
|
|
$httpBody = '';
|
||
|
|
$multipart = false;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// path params
|
||
|
|
if ($zone !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'zone' . '}',
|
||
|
|
ObjectSerializer::toPathValue($zone),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($snapshot_id !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'snapshot_id' . '}',
|
||
|
|
ObjectSerializer::toPathValue($snapshot_id),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
['application/json', ],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (isset($update_snapshot_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_snapshot_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $update_snapshot_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;
|
||
|
|
}
|
||
|
|
}
|