2714 lines
119 KiB
PHP
2714 lines
119 KiB
PHP
<?php
|
|
/**
|
|
* GatewaysApi
|
|
* PHP version 7.4
|
|
*
|
|
* @category Class
|
|
* @package OpenAPI\Client
|
|
* @author OpenAPI Generator team
|
|
* @link https://openapi-generator.tech
|
|
*/
|
|
|
|
/**
|
|
* Public Gateways API
|
|
*
|
|
* Scaleway Public Gateways are building blocks for your infrastructure on Scaleway's public cloud. They sit at the border of Private Networks and provide access to/from other networks or the Internet. As well as this, Public Gateways offer a host of managed features and services to facilitate the management of resources in your Private Network, including NAT to map private IP addresses in the Private Network to the public IP address of the Public Gateway. (switchcolumn) <Message type=\"tip\"> To create and manage your Private Networks, check out the [VPC API](https://www.scaleway.com/en/developers/api/vpc). </Message> (switchcolumn) ## Concepts Refer to our [dedicated concepts page](https://www.scaleway.com/en/docs/public-gateways/concepts/) to find definitions of all terminology related to Public Gateways, including NAT, SSH bastion and more. (switchcolumn) (switchcolumn) ## Quickstart 1. Configure your environment variables. <Message type=\"note\"> This is an optional step that seeks to simplify your usage of the Public Gateways API. </Message> ```bash export SCW_SECRET_KEY=\"<API secret key>\" export SCW_DEFAULT_ZONE=\"<Scaleway default Availability Zone>\" export SCW_PROJECT_ID=\"<Scaleway Project ID>\" ``` 2. **Choose a Public Gateway type**: Public Gateways come in different shapes and sizes, with different network capabilities and pricing. When you create your Public Gateway, you need to include the required Public Gateway type in the request. Use the following call to get a list of available Public Gateway offer types and their details: ```bash curl -X GET \\ -H \"X-Auth-Token: $SCW_SECRET_KEY\" \\ -H \"Content-Type: application/json\" \\ \"https://api.scaleway.com/vpc-gw/v2/zones/$SCW_DEFAULT_ZONE/gateway-types\" ``` 3. **Create a Public Gateway**: run the following command to create a Public Gateway. You can customize the details in the payload (name, description, tags, etc) to your needs: use the information below to adjust the payload as necessary. ```bash curl -X POST \\ -H \"X-Auth-Token: $SCW_SECRET_KEY\" \\ -H \"Content-Type: application/json\" \\ \"https://api.scaleway.com/vpc-gw/v2/zones/$SCW_DEFAULT_ZONE/gateways\" \\ -d '{ \"type\": \"VPC-GW-S\", \"name\": \"my-new-gateway\", \"tags\": [\"my-first-tag\", \"my-second-tag\"], \"project_id\": \"'\"$SCW_PROJECT_ID\"'\" }' ``` | Parameter | Description | Valid values | |-----------------|-----------------------------------------------------|-------------------------------| | type | The type of Public Gateway (commercial offer type) to create. Use the Gateway Types endpoint to get a list of offer types. | Any valid offer type string, e.g. `VPC-GW-S` | | name | A name of your choice for the Public Gateway | Any string containing only alphanumeric characters and dashes, e.g. `my-new-gateway`. | | tags | A list of tags to describe your Public Gateway. These can help you manage and filter your gateways. | A list of alphanumeric strings, e.g. `[\"my-first-tag`, `my-second-tag` | | project_id | The Scaleway Project ID to create the Public Gateway in. | A valid Scaleway Project ID, e.g. `f5fe13a0-b9c7-11ed-afa1-0242ac120002` | **Note**: Further parameters are available, but for the purposes of this quickstart we have included only the essentials. See the `Create a Public Gateway` endpoint documentation below for full details of all possible parameters. 4. **Get a list of your Public Gateways**: run the following command to get a list of all your Public Gateways. ```bash curl -X GET \\ -H \"X-Auth-Token: $SCW_SECRET_KEY\" \\ -H \"Content-Type: application/json\" \\ \"https://api.scaleway.com/vpc-gw/v2/zones/$SCW_DEFAULT_ZONE/gateways\" ``` 5. **Attach a Private Network to a Public Gateway**: run the following command to attach a Private Network to your Public Gateway, and make all the Gateway's services such as NAT available to the Private Network. You can customize the details in the payload to your needs: use the information below to adjust the payload as necessary. <Message type=\"tip\"> If you haven't created a Private Network yet, see the [Private Networks](https://www/scaleway.com/en/developers/api/vpc/) documentation to learn how to do so. Ensure you retain the ID of the Private Network. </Message> ```bash curl -X POST \\ -H \"X-Auth-Token: $SCW_SECRET_KEY\" \\ -H \"Content-Type: application/json\" \\ \"https://api.scaleway.com/vpc-gw/v2/zones/$SCW_DEFAULT_ZONE/gateway-networks\" \\ -d '{ \"gateway_id\": \"b1b2edda-9364-422d-93f2-ad04e6a054dc\", \"private_network_id\": \"548dbcc3-8b78-486f-a79a-c3f5a17642f9\", \"enable_masquerade\": true }' ``` This configuration will set up the Public Gateway as a NAT gateway, masquerading traffic sent to it to the outer internet to provide internet access to resources in the Private Network. | Parameter | Description | Valid values | |-----------------|-----------------------------------------------------|-------------------------------| | gateway_id | The Public Gateway ID of an existing Public Gateway | Any valid Public Gateway ID, e.g. `b1b2edda-9364-422d-93f2-ad04e6a054dc` | | private_network_id | The Private Network ID of an existing Private Network | Any valid Private Network ID in the same Availability Zone as the Public Gateway, e.g. `548dbcc3-8b78-486f-a79a-c3f5a17642f9` | | enable_masquerade | Defines whether the gateway should masquerade traffic for the attached Private Network (i.e. whether to enable dynamic NAT) | A boolean value, e.g. `true` | <Message type=\"note\"> Further parameters are available, but for the purposes of this quickstart we have included only the essentials. See the [Attach a gateway to a Private Network](#path-gateway-networks-attach-a-public-gateway-to-a-private-network) documentation below for full details of all possible parameters. </Message> 6. **Delete a Public Gateway**: run the following call to delete your Public Gateway. Ensure that you replace `<PUBLIC-GATEWAY-ID>` in the URL with the ID of the Public Gateway you want to delete. ```bash curl -X DELETE \\ -H \"X-Auth-Token: $SCW_SECRET_KEY\" \\ -H \"Content-Type: application/json\" \\ \"https://api.scaleway.com/vpc-gw/v2/zones/$SCW_DEFAULT_ZONE/gateways/<PUBLIC-GATEWAY-ID>\" ``` The expected successful response is empty. (switchcolumn) <Message type=\"requirement\"> - You have a [Scaleway account](https://console.scaleway.com/) - You have [created an API key](https://www.scaleway.com/en/docs/iam/how-to/create-api-keys/) and that the API key has sufficient [IAM permissions](https://www.scaleway.com/en/docs/iam/reference-content/permission-sets/) to perform the actions described on this page - You have [installed `curl`](https://curl.se/download.html) </Message> (switchcolumn) ## Technical limitations The following limitations apply to Public Gateways: - A maximum of eight (8) Private Networks can be plugged into a single Public Gateway - Note that the Public Gateway takes some time to start up, and actions on it are impossible unless it is in the `running` state. To check the current state of a Public Gateway, use the [Get a Public Gateway](#path-gateways-get-a-public-gateway) endpoint to get information for your gateway: the `status` field of the response will tell you if it is running or in another state. - For further information about Public Gateway limitations see our [dedicated documentation](https://www.scaleway.com/en/docs/public-gateways/troubleshooting/gw-limitations/). ## Technical information ### Availability Zones Public Gateways can be deployed in the following Availability Zones: | Name | API ID | |-----------|-----------------------| | Paris | `fr-par-1` `fr-par-2` | | Amsterdam | `nl-ams-1` `nl-ams-2` `nl-ams-3` | | Warsaw | `pl-waw-1` `pl-waw-2` `pl-waw-3` | The Scaleway Public Gateways API is a **zoned** API, meaning that each call must specify in its path parameters the Availability Zone for the resources concerned by the call. ## Going further For more help using Scaleway Public Gateways, check out the following resources: - Our [main documentation](https://www.scaleway.com/en/docs/public-gateways/) - The #public-gateway channel on our [Slack Community](https://www.scaleway.com/en/docs/tutorials/scaleway-slack-community/) - Our [support ticketing system](https://www.scaleway.com/en/docs/account/how-to/open-a-support-ticket/).
|
|
*
|
|
* The version of the OpenAPI document: v2
|
|
* 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;
|
|
|
|
/**
|
|
* GatewaysApi Class Doc Comment
|
|
*
|
|
* @category Class
|
|
* @package OpenAPI\Client
|
|
* @author OpenAPI Generator team
|
|
* @link https://openapi-generator.tech
|
|
*/
|
|
class GatewaysApi
|
|
{
|
|
/**
|
|
* @var ClientInterface
|
|
*/
|
|
protected $client;
|
|
|
|
/**
|
|
* @var Configuration
|
|
*/
|
|
protected $config;
|
|
|
|
/**
|
|
* @var HeaderSelector
|
|
*/
|
|
protected $headerSelector;
|
|
|
|
/**
|
|
* @var int Host index
|
|
*/
|
|
protected $hostIndex;
|
|
|
|
/** @var string[] $contentTypes **/
|
|
public const contentTypes = [
|
|
'createGateway' => [
|
|
'application/json',
|
|
],
|
|
'deleteGateway' => [
|
|
'application/json',
|
|
],
|
|
'getGateway' => [
|
|
'application/json',
|
|
],
|
|
'listGateways' => [
|
|
'application/json',
|
|
],
|
|
'refreshSSHKeys' => [
|
|
'application/json',
|
|
],
|
|
'updateGateway' => [
|
|
'application/json',
|
|
],
|
|
'upgradeGateway' => [
|
|
'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 createGateway
|
|
*
|
|
* Create a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param \OpenAPI\Client\Model\CreateGatewayRequest $create_gateway_request create_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createGateway'] 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\ScalewayVpcGwV2Gateway
|
|
*/
|
|
public function createGateway($zone, $create_gateway_request, string $contentType = self::contentTypes['createGateway'][0])
|
|
{
|
|
list($response) = $this->createGatewayWithHttpInfo($zone, $create_gateway_request, $contentType);
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Operation createGatewayWithHttpInfo
|
|
*
|
|
* Create a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param \OpenAPI\Client\Model\CreateGatewayRequest $create_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createGateway'] 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\ScalewayVpcGwV2Gateway, HTTP status code, HTTP response headers (array of strings)
|
|
*/
|
|
public function createGatewayWithHttpInfo($zone, $create_gateway_request, string $contentType = self::contentTypes['createGateway'][0])
|
|
{
|
|
$request = $this->createGatewayRequest($zone, $create_gateway_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\ScalewayVpcGwV2Gateway' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway' !== '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\ScalewayVpcGwV2Gateway', []),
|
|
$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\ScalewayVpcGwV2Gateway';
|
|
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\ScalewayVpcGwV2Gateway',
|
|
$e->getResponseHeaders()
|
|
);
|
|
$e->setResponseObject($data);
|
|
break;
|
|
}
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Operation createGatewayAsync
|
|
*
|
|
* Create a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param \OpenAPI\Client\Model\CreateGatewayRequest $create_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function createGatewayAsync($zone, $create_gateway_request, string $contentType = self::contentTypes['createGateway'][0])
|
|
{
|
|
return $this->createGatewayAsyncWithHttpInfo($zone, $create_gateway_request, $contentType)
|
|
->then(
|
|
function ($response) {
|
|
return $response[0];
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation createGatewayAsyncWithHttpInfo
|
|
*
|
|
* Create a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param \OpenAPI\Client\Model\CreateGatewayRequest $create_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function createGatewayAsyncWithHttpInfo($zone, $create_gateway_request, string $contentType = self::contentTypes['createGateway'][0])
|
|
{
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway';
|
|
$request = $this->createGatewayRequest($zone, $create_gateway_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 'createGateway'
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param \OpenAPI\Client\Model\CreateGatewayRequest $create_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['createGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Psr7\Request
|
|
*/
|
|
public function createGatewayRequest($zone, $create_gateway_request, string $contentType = self::contentTypes['createGateway'][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 createGateway'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'create_gateway_request' is set
|
|
if ($create_gateway_request === null || (is_array($create_gateway_request) && count($create_gateway_request) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $create_gateway_request when calling createGateway'
|
|
);
|
|
}
|
|
|
|
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways';
|
|
$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_gateway_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_gateway_request));
|
|
} else {
|
|
$httpBody = $create_gateway_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 deleteGateway
|
|
*
|
|
* Delete a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to delete. (UUID format) (required)
|
|
* @param bool $delete_ip Defines whether the PGW's IP should be deleted. (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGateway'] 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\ScalewayVpcGwV2Gateway
|
|
*/
|
|
public function deleteGateway($zone, $gateway_id, $delete_ip, string $contentType = self::contentTypes['deleteGateway'][0])
|
|
{
|
|
list($response) = $this->deleteGatewayWithHttpInfo($zone, $gateway_id, $delete_ip, $contentType);
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Operation deleteGatewayWithHttpInfo
|
|
*
|
|
* Delete a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to delete. (UUID format) (required)
|
|
* @param bool $delete_ip Defines whether the PGW's IP should be deleted. (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGateway'] 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\ScalewayVpcGwV2Gateway, HTTP status code, HTTP response headers (array of strings)
|
|
*/
|
|
public function deleteGatewayWithHttpInfo($zone, $gateway_id, $delete_ip, string $contentType = self::contentTypes['deleteGateway'][0])
|
|
{
|
|
$request = $this->deleteGatewayRequest($zone, $gateway_id, $delete_ip, $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\ScalewayVpcGwV2Gateway' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway' !== '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\ScalewayVpcGwV2Gateway', []),
|
|
$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\ScalewayVpcGwV2Gateway';
|
|
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\ScalewayVpcGwV2Gateway',
|
|
$e->getResponseHeaders()
|
|
);
|
|
$e->setResponseObject($data);
|
|
break;
|
|
}
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Operation deleteGatewayAsync
|
|
*
|
|
* Delete a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to delete. (UUID format) (required)
|
|
* @param bool $delete_ip Defines whether the PGW's IP should be deleted. (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function deleteGatewayAsync($zone, $gateway_id, $delete_ip, string $contentType = self::contentTypes['deleteGateway'][0])
|
|
{
|
|
return $this->deleteGatewayAsyncWithHttpInfo($zone, $gateway_id, $delete_ip, $contentType)
|
|
->then(
|
|
function ($response) {
|
|
return $response[0];
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation deleteGatewayAsyncWithHttpInfo
|
|
*
|
|
* Delete a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to delete. (UUID format) (required)
|
|
* @param bool $delete_ip Defines whether the PGW's IP should be deleted. (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function deleteGatewayAsyncWithHttpInfo($zone, $gateway_id, $delete_ip, string $contentType = self::contentTypes['deleteGateway'][0])
|
|
{
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway';
|
|
$request = $this->deleteGatewayRequest($zone, $gateway_id, $delete_ip, $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 'deleteGateway'
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to delete. (UUID format) (required)
|
|
* @param bool $delete_ip Defines whether the PGW's IP should be deleted. (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Psr7\Request
|
|
*/
|
|
public function deleteGatewayRequest($zone, $gateway_id, $delete_ip, string $contentType = self::contentTypes['deleteGateway'][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 deleteGateway'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'gateway_id' is set
|
|
if ($gateway_id === null || (is_array($gateway_id) && count($gateway_id) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $gateway_id when calling deleteGateway'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'delete_ip' is set
|
|
if ($delete_ip === null || (is_array($delete_ip) && count($delete_ip) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $delete_ip when calling deleteGateway'
|
|
);
|
|
}
|
|
|
|
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways/{gateway_id}';
|
|
$formParams = [];
|
|
$queryParams = [];
|
|
$headerParams = [];
|
|
$httpBody = '';
|
|
$multipart = false;
|
|
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$delete_ip,
|
|
'delete_ip', // param base name
|
|
'boolean', // openApiType
|
|
'form', // style
|
|
true, // explode
|
|
true // required
|
|
) ?? []);
|
|
|
|
|
|
// path params
|
|
if ($zone !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'zone' . '}',
|
|
ObjectSerializer::toPathValue($zone),
|
|
$resourcePath
|
|
);
|
|
}
|
|
// path params
|
|
if ($gateway_id !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'gateway_id' . '}',
|
|
ObjectSerializer::toPathValue($gateway_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(
|
|
'DELETE',
|
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
|
$headers,
|
|
$httpBody
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation getGateway
|
|
*
|
|
* Get a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to fetch. (UUID format) (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGateway'] 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\ScalewayVpcGwV2Gateway
|
|
*/
|
|
public function getGateway($zone, $gateway_id, string $contentType = self::contentTypes['getGateway'][0])
|
|
{
|
|
list($response) = $this->getGatewayWithHttpInfo($zone, $gateway_id, $contentType);
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Operation getGatewayWithHttpInfo
|
|
*
|
|
* Get a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to fetch. (UUID format) (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGateway'] 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\ScalewayVpcGwV2Gateway, HTTP status code, HTTP response headers (array of strings)
|
|
*/
|
|
public function getGatewayWithHttpInfo($zone, $gateway_id, string $contentType = self::contentTypes['getGateway'][0])
|
|
{
|
|
$request = $this->getGatewayRequest($zone, $gateway_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\ScalewayVpcGwV2Gateway' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway' !== '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\ScalewayVpcGwV2Gateway', []),
|
|
$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\ScalewayVpcGwV2Gateway';
|
|
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\ScalewayVpcGwV2Gateway',
|
|
$e->getResponseHeaders()
|
|
);
|
|
$e->setResponseObject($data);
|
|
break;
|
|
}
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Operation getGatewayAsync
|
|
*
|
|
* Get a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to fetch. (UUID format) (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function getGatewayAsync($zone, $gateway_id, string $contentType = self::contentTypes['getGateway'][0])
|
|
{
|
|
return $this->getGatewayAsyncWithHttpInfo($zone, $gateway_id, $contentType)
|
|
->then(
|
|
function ($response) {
|
|
return $response[0];
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation getGatewayAsyncWithHttpInfo
|
|
*
|
|
* Get a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to fetch. (UUID format) (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function getGatewayAsyncWithHttpInfo($zone, $gateway_id, string $contentType = self::contentTypes['getGateway'][0])
|
|
{
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway';
|
|
$request = $this->getGatewayRequest($zone, $gateway_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 'getGateway'
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to fetch. (UUID format) (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Psr7\Request
|
|
*/
|
|
public function getGatewayRequest($zone, $gateway_id, string $contentType = self::contentTypes['getGateway'][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 getGateway'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'gateway_id' is set
|
|
if ($gateway_id === null || (is_array($gateway_id) && count($gateway_id) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $gateway_id when calling getGateway'
|
|
);
|
|
}
|
|
|
|
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways/{gateway_id}';
|
|
$formParams = [];
|
|
$queryParams = [];
|
|
$headerParams = [];
|
|
$httpBody = '';
|
|
$multipart = false;
|
|
|
|
|
|
|
|
// path params
|
|
if ($zone !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'zone' . '}',
|
|
ObjectSerializer::toPathValue($zone),
|
|
$resourcePath
|
|
);
|
|
}
|
|
// path params
|
|
if ($gateway_id !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'gateway_id' . '}',
|
|
ObjectSerializer::toPathValue($gateway_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 listGateways
|
|
*
|
|
* List Public Gateways
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string|null $order_by Order in which to return results. (optional, default to 'created_at_asc')
|
|
* @param int|null $page Page number to return. (optional)
|
|
* @param int|null $page_size Gateways per page. (optional)
|
|
* @param string|null $organization_id Include only gateways in this Organization. (UUID format) (optional)
|
|
* @param string|null $project_id Include only gateways in this Project. (UUID format) (optional)
|
|
* @param string|null $name Filter for gateways which have this search term in their name. (optional)
|
|
* @param string[]|null $tags Filter for gateways with these tags. (optional)
|
|
* @param string[]|null $types Filter for gateways of these types. (optional)
|
|
* @param \OpenAPI\Client\Model\ScalewayVpcGwV2GatewayStatus[]|null $status Filter for gateways with these status. Use `unknown` to include all statuses. (optional)
|
|
* @param string[]|null $private_network_ids Filter for gateways attached to these Private Networks. (optional)
|
|
* @param bool|null $include_legacy Include also legacy gateways. (optional)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listGateways'] 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\ScalewayVpcGwV2ListGatewaysResponse
|
|
*/
|
|
public function listGateways($zone, $order_by = 'created_at_asc', $page = null, $page_size = null, $organization_id = null, $project_id = null, $name = null, $tags = null, $types = null, $status = null, $private_network_ids = null, $include_legacy = null, string $contentType = self::contentTypes['listGateways'][0])
|
|
{
|
|
list($response) = $this->listGatewaysWithHttpInfo($zone, $order_by, $page, $page_size, $organization_id, $project_id, $name, $tags, $types, $status, $private_network_ids, $include_legacy, $contentType);
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Operation listGatewaysWithHttpInfo
|
|
*
|
|
* List Public Gateways
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string|null $order_by Order in which to return results. (optional, default to 'created_at_asc')
|
|
* @param int|null $page Page number to return. (optional)
|
|
* @param int|null $page_size Gateways per page. (optional)
|
|
* @param string|null $organization_id Include only gateways in this Organization. (UUID format) (optional)
|
|
* @param string|null $project_id Include only gateways in this Project. (UUID format) (optional)
|
|
* @param string|null $name Filter for gateways which have this search term in their name. (optional)
|
|
* @param string[]|null $tags Filter for gateways with these tags. (optional)
|
|
* @param string[]|null $types Filter for gateways of these types. (optional)
|
|
* @param \OpenAPI\Client\Model\ScalewayVpcGwV2GatewayStatus[]|null $status Filter for gateways with these status. Use `unknown` to include all statuses. (optional)
|
|
* @param string[]|null $private_network_ids Filter for gateways attached to these Private Networks. (optional)
|
|
* @param bool|null $include_legacy Include also legacy gateways. (optional)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listGateways'] 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\ScalewayVpcGwV2ListGatewaysResponse, HTTP status code, HTTP response headers (array of strings)
|
|
*/
|
|
public function listGatewaysWithHttpInfo($zone, $order_by = 'created_at_asc', $page = null, $page_size = null, $organization_id = null, $project_id = null, $name = null, $tags = null, $types = null, $status = null, $private_network_ids = null, $include_legacy = null, string $contentType = self::contentTypes['listGateways'][0])
|
|
{
|
|
$request = $this->listGatewaysRequest($zone, $order_by, $page, $page_size, $organization_id, $project_id, $name, $tags, $types, $status, $private_network_ids, $include_legacy, $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\ScalewayVpcGwV2ListGatewaysResponse' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayVpcGwV2ListGatewaysResponse' !== '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\ScalewayVpcGwV2ListGatewaysResponse', []),
|
|
$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\ScalewayVpcGwV2ListGatewaysResponse';
|
|
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\ScalewayVpcGwV2ListGatewaysResponse',
|
|
$e->getResponseHeaders()
|
|
);
|
|
$e->setResponseObject($data);
|
|
break;
|
|
}
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Operation listGatewaysAsync
|
|
*
|
|
* List Public Gateways
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string|null $order_by Order in which to return results. (optional, default to 'created_at_asc')
|
|
* @param int|null $page Page number to return. (optional)
|
|
* @param int|null $page_size Gateways per page. (optional)
|
|
* @param string|null $organization_id Include only gateways in this Organization. (UUID format) (optional)
|
|
* @param string|null $project_id Include only gateways in this Project. (UUID format) (optional)
|
|
* @param string|null $name Filter for gateways which have this search term in their name. (optional)
|
|
* @param string[]|null $tags Filter for gateways with these tags. (optional)
|
|
* @param string[]|null $types Filter for gateways of these types. (optional)
|
|
* @param \OpenAPI\Client\Model\ScalewayVpcGwV2GatewayStatus[]|null $status Filter for gateways with these status. Use `unknown` to include all statuses. (optional)
|
|
* @param string[]|null $private_network_ids Filter for gateways attached to these Private Networks. (optional)
|
|
* @param bool|null $include_legacy Include also legacy gateways. (optional)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listGateways'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function listGatewaysAsync($zone, $order_by = 'created_at_asc', $page = null, $page_size = null, $organization_id = null, $project_id = null, $name = null, $tags = null, $types = null, $status = null, $private_network_ids = null, $include_legacy = null, string $contentType = self::contentTypes['listGateways'][0])
|
|
{
|
|
return $this->listGatewaysAsyncWithHttpInfo($zone, $order_by, $page, $page_size, $organization_id, $project_id, $name, $tags, $types, $status, $private_network_ids, $include_legacy, $contentType)
|
|
->then(
|
|
function ($response) {
|
|
return $response[0];
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation listGatewaysAsyncWithHttpInfo
|
|
*
|
|
* List Public Gateways
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string|null $order_by Order in which to return results. (optional, default to 'created_at_asc')
|
|
* @param int|null $page Page number to return. (optional)
|
|
* @param int|null $page_size Gateways per page. (optional)
|
|
* @param string|null $organization_id Include only gateways in this Organization. (UUID format) (optional)
|
|
* @param string|null $project_id Include only gateways in this Project. (UUID format) (optional)
|
|
* @param string|null $name Filter for gateways which have this search term in their name. (optional)
|
|
* @param string[]|null $tags Filter for gateways with these tags. (optional)
|
|
* @param string[]|null $types Filter for gateways of these types. (optional)
|
|
* @param \OpenAPI\Client\Model\ScalewayVpcGwV2GatewayStatus[]|null $status Filter for gateways with these status. Use `unknown` to include all statuses. (optional)
|
|
* @param string[]|null $private_network_ids Filter for gateways attached to these Private Networks. (optional)
|
|
* @param bool|null $include_legacy Include also legacy gateways. (optional)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listGateways'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function listGatewaysAsyncWithHttpInfo($zone, $order_by = 'created_at_asc', $page = null, $page_size = null, $organization_id = null, $project_id = null, $name = null, $tags = null, $types = null, $status = null, $private_network_ids = null, $include_legacy = null, string $contentType = self::contentTypes['listGateways'][0])
|
|
{
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayVpcGwV2ListGatewaysResponse';
|
|
$request = $this->listGatewaysRequest($zone, $order_by, $page, $page_size, $organization_id, $project_id, $name, $tags, $types, $status, $private_network_ids, $include_legacy, $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 'listGateways'
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string|null $order_by Order in which to return results. (optional, default to 'created_at_asc')
|
|
* @param int|null $page Page number to return. (optional)
|
|
* @param int|null $page_size Gateways per page. (optional)
|
|
* @param string|null $organization_id Include only gateways in this Organization. (UUID format) (optional)
|
|
* @param string|null $project_id Include only gateways in this Project. (UUID format) (optional)
|
|
* @param string|null $name Filter for gateways which have this search term in their name. (optional)
|
|
* @param string[]|null $tags Filter for gateways with these tags. (optional)
|
|
* @param string[]|null $types Filter for gateways of these types. (optional)
|
|
* @param \OpenAPI\Client\Model\ScalewayVpcGwV2GatewayStatus[]|null $status Filter for gateways with these status. Use `unknown` to include all statuses. (optional)
|
|
* @param string[]|null $private_network_ids Filter for gateways attached to these Private Networks. (optional)
|
|
* @param bool|null $include_legacy Include also legacy gateways. (optional)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['listGateways'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Psr7\Request
|
|
*/
|
|
public function listGatewaysRequest($zone, $order_by = 'created_at_asc', $page = null, $page_size = null, $organization_id = null, $project_id = null, $name = null, $tags = null, $types = null, $status = null, $private_network_ids = null, $include_legacy = null, string $contentType = self::contentTypes['listGateways'][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 listGateways'
|
|
);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways';
|
|
$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(
|
|
$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(
|
|
$organization_id,
|
|
'organization_id', // 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(
|
|
$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
|
|
) ?? []);
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$types,
|
|
'types', // param base name
|
|
'array', // openApiType
|
|
'form', // style
|
|
true, // explode
|
|
false // required
|
|
) ?? []);
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$status,
|
|
'status', // param base name
|
|
'array', // openApiType
|
|
'form', // style
|
|
true, // explode
|
|
false // required
|
|
) ?? []);
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$private_network_ids,
|
|
'private_network_ids', // param base name
|
|
'array', // openApiType
|
|
'form', // style
|
|
true, // explode
|
|
false // required
|
|
) ?? []);
|
|
// query params
|
|
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
$include_legacy,
|
|
'include_legacy', // param base name
|
|
'boolean', // 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 refreshSSHKeys
|
|
*
|
|
* Refresh a Public Gateway's SSH keys
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to refresh SSH keys on. (UUID format) (required)
|
|
* @param object $body body (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshSSHKeys'] 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\ScalewayVpcGwV2Gateway
|
|
*/
|
|
public function refreshSSHKeys($zone, $gateway_id, $body, string $contentType = self::contentTypes['refreshSSHKeys'][0])
|
|
{
|
|
list($response) = $this->refreshSSHKeysWithHttpInfo($zone, $gateway_id, $body, $contentType);
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Operation refreshSSHKeysWithHttpInfo
|
|
*
|
|
* Refresh a Public Gateway's SSH keys
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to refresh SSH keys on. (UUID format) (required)
|
|
* @param object $body (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshSSHKeys'] 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\ScalewayVpcGwV2Gateway, HTTP status code, HTTP response headers (array of strings)
|
|
*/
|
|
public function refreshSSHKeysWithHttpInfo($zone, $gateway_id, $body, string $contentType = self::contentTypes['refreshSSHKeys'][0])
|
|
{
|
|
$request = $this->refreshSSHKeysRequest($zone, $gateway_id, $body, $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\ScalewayVpcGwV2Gateway' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway' !== '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\ScalewayVpcGwV2Gateway', []),
|
|
$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\ScalewayVpcGwV2Gateway';
|
|
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\ScalewayVpcGwV2Gateway',
|
|
$e->getResponseHeaders()
|
|
);
|
|
$e->setResponseObject($data);
|
|
break;
|
|
}
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Operation refreshSSHKeysAsync
|
|
*
|
|
* Refresh a Public Gateway's SSH keys
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to refresh SSH keys on. (UUID format) (required)
|
|
* @param object $body (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshSSHKeys'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function refreshSSHKeysAsync($zone, $gateway_id, $body, string $contentType = self::contentTypes['refreshSSHKeys'][0])
|
|
{
|
|
return $this->refreshSSHKeysAsyncWithHttpInfo($zone, $gateway_id, $body, $contentType)
|
|
->then(
|
|
function ($response) {
|
|
return $response[0];
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation refreshSSHKeysAsyncWithHttpInfo
|
|
*
|
|
* Refresh a Public Gateway's SSH keys
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to refresh SSH keys on. (UUID format) (required)
|
|
* @param object $body (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshSSHKeys'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function refreshSSHKeysAsyncWithHttpInfo($zone, $gateway_id, $body, string $contentType = self::contentTypes['refreshSSHKeys'][0])
|
|
{
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway';
|
|
$request = $this->refreshSSHKeysRequest($zone, $gateway_id, $body, $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 'refreshSSHKeys'
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to refresh SSH keys on. (UUID format) (required)
|
|
* @param object $body (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshSSHKeys'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Psr7\Request
|
|
*/
|
|
public function refreshSSHKeysRequest($zone, $gateway_id, $body, string $contentType = self::contentTypes['refreshSSHKeys'][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 refreshSSHKeys'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'gateway_id' is set
|
|
if ($gateway_id === null || (is_array($gateway_id) && count($gateway_id) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $gateway_id when calling refreshSSHKeys'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'body' is set
|
|
if ($body === null || (is_array($body) && count($body) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $body when calling refreshSSHKeys'
|
|
);
|
|
}
|
|
|
|
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/refresh-ssh-keys';
|
|
$formParams = [];
|
|
$queryParams = [];
|
|
$headerParams = [];
|
|
$httpBody = '';
|
|
$multipart = false;
|
|
|
|
|
|
|
|
// path params
|
|
if ($zone !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'zone' . '}',
|
|
ObjectSerializer::toPathValue($zone),
|
|
$resourcePath
|
|
);
|
|
}
|
|
// path params
|
|
if ($gateway_id !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'gateway_id' . '}',
|
|
ObjectSerializer::toPathValue($gateway_id),
|
|
$resourcePath
|
|
);
|
|
}
|
|
|
|
|
|
$headers = $this->headerSelector->selectHeaders(
|
|
['application/json', ],
|
|
$contentType,
|
|
$multipart
|
|
);
|
|
|
|
// for model (json/xml)
|
|
if (isset($body)) {
|
|
if (stripos($headers['Content-Type'], 'application/json') !== false) {
|
|
# if Content-Type contains "application/json", json_encode the body
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body));
|
|
} else {
|
|
$httpBody = $body;
|
|
}
|
|
} 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 updateGateway
|
|
*
|
|
* Update a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to update. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpdateGatewayRequest $update_gateway_request update_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGateway'] 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\ScalewayVpcGwV2Gateway
|
|
*/
|
|
public function updateGateway($zone, $gateway_id, $update_gateway_request, string $contentType = self::contentTypes['updateGateway'][0])
|
|
{
|
|
list($response) = $this->updateGatewayWithHttpInfo($zone, $gateway_id, $update_gateway_request, $contentType);
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Operation updateGatewayWithHttpInfo
|
|
*
|
|
* Update a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to update. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpdateGatewayRequest $update_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGateway'] 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\ScalewayVpcGwV2Gateway, HTTP status code, HTTP response headers (array of strings)
|
|
*/
|
|
public function updateGatewayWithHttpInfo($zone, $gateway_id, $update_gateway_request, string $contentType = self::contentTypes['updateGateway'][0])
|
|
{
|
|
$request = $this->updateGatewayRequest($zone, $gateway_id, $update_gateway_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\ScalewayVpcGwV2Gateway' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway' !== '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\ScalewayVpcGwV2Gateway', []),
|
|
$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\ScalewayVpcGwV2Gateway';
|
|
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\ScalewayVpcGwV2Gateway',
|
|
$e->getResponseHeaders()
|
|
);
|
|
$e->setResponseObject($data);
|
|
break;
|
|
}
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Operation updateGatewayAsync
|
|
*
|
|
* Update a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to update. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpdateGatewayRequest $update_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function updateGatewayAsync($zone, $gateway_id, $update_gateway_request, string $contentType = self::contentTypes['updateGateway'][0])
|
|
{
|
|
return $this->updateGatewayAsyncWithHttpInfo($zone, $gateway_id, $update_gateway_request, $contentType)
|
|
->then(
|
|
function ($response) {
|
|
return $response[0];
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation updateGatewayAsyncWithHttpInfo
|
|
*
|
|
* Update a Public Gateway
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to update. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpdateGatewayRequest $update_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function updateGatewayAsyncWithHttpInfo($zone, $gateway_id, $update_gateway_request, string $contentType = self::contentTypes['updateGateway'][0])
|
|
{
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway';
|
|
$request = $this->updateGatewayRequest($zone, $gateway_id, $update_gateway_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 'updateGateway'
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to update. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpdateGatewayRequest $update_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Psr7\Request
|
|
*/
|
|
public function updateGatewayRequest($zone, $gateway_id, $update_gateway_request, string $contentType = self::contentTypes['updateGateway'][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 updateGateway'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'gateway_id' is set
|
|
if ($gateway_id === null || (is_array($gateway_id) && count($gateway_id) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $gateway_id when calling updateGateway'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'update_gateway_request' is set
|
|
if ($update_gateway_request === null || (is_array($update_gateway_request) && count($update_gateway_request) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $update_gateway_request when calling updateGateway'
|
|
);
|
|
}
|
|
|
|
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways/{gateway_id}';
|
|
$formParams = [];
|
|
$queryParams = [];
|
|
$headerParams = [];
|
|
$httpBody = '';
|
|
$multipart = false;
|
|
|
|
|
|
|
|
// path params
|
|
if ($zone !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'zone' . '}',
|
|
ObjectSerializer::toPathValue($zone),
|
|
$resourcePath
|
|
);
|
|
}
|
|
// path params
|
|
if ($gateway_id !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'gateway_id' . '}',
|
|
ObjectSerializer::toPathValue($gateway_id),
|
|
$resourcePath
|
|
);
|
|
}
|
|
|
|
|
|
$headers = $this->headerSelector->selectHeaders(
|
|
['application/json', ],
|
|
$contentType,
|
|
$multipart
|
|
);
|
|
|
|
// for model (json/xml)
|
|
if (isset($update_gateway_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_gateway_request));
|
|
} else {
|
|
$httpBody = $update_gateway_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
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation upgradeGateway
|
|
*
|
|
* Upgrade a Public Gateway to the latest version and/or to a different commercial offer type
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to upgrade. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpgradeGatewayRequest $upgrade_gateway_request upgrade_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upgradeGateway'] 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\ScalewayVpcGwV2Gateway
|
|
*/
|
|
public function upgradeGateway($zone, $gateway_id, $upgrade_gateway_request, string $contentType = self::contentTypes['upgradeGateway'][0])
|
|
{
|
|
list($response) = $this->upgradeGatewayWithHttpInfo($zone, $gateway_id, $upgrade_gateway_request, $contentType);
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Operation upgradeGatewayWithHttpInfo
|
|
*
|
|
* Upgrade a Public Gateway to the latest version and/or to a different commercial offer type
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to upgrade. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpgradeGatewayRequest $upgrade_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upgradeGateway'] 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\ScalewayVpcGwV2Gateway, HTTP status code, HTTP response headers (array of strings)
|
|
*/
|
|
public function upgradeGatewayWithHttpInfo($zone, $gateway_id, $upgrade_gateway_request, string $contentType = self::contentTypes['upgradeGateway'][0])
|
|
{
|
|
$request = $this->upgradeGatewayRequest($zone, $gateway_id, $upgrade_gateway_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\ScalewayVpcGwV2Gateway' === '\SplFileObject') {
|
|
$content = $response->getBody(); //stream goes to serializer
|
|
} else {
|
|
$content = (string) $response->getBody();
|
|
if ('\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway' !== '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\ScalewayVpcGwV2Gateway', []),
|
|
$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\ScalewayVpcGwV2Gateway';
|
|
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\ScalewayVpcGwV2Gateway',
|
|
$e->getResponseHeaders()
|
|
);
|
|
$e->setResponseObject($data);
|
|
break;
|
|
}
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Operation upgradeGatewayAsync
|
|
*
|
|
* Upgrade a Public Gateway to the latest version and/or to a different commercial offer type
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to upgrade. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpgradeGatewayRequest $upgrade_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upgradeGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function upgradeGatewayAsync($zone, $gateway_id, $upgrade_gateway_request, string $contentType = self::contentTypes['upgradeGateway'][0])
|
|
{
|
|
return $this->upgradeGatewayAsyncWithHttpInfo($zone, $gateway_id, $upgrade_gateway_request, $contentType)
|
|
->then(
|
|
function ($response) {
|
|
return $response[0];
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Operation upgradeGatewayAsyncWithHttpInfo
|
|
*
|
|
* Upgrade a Public Gateway to the latest version and/or to a different commercial offer type
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to upgrade. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpgradeGatewayRequest $upgrade_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upgradeGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
|
*/
|
|
public function upgradeGatewayAsyncWithHttpInfo($zone, $gateway_id, $upgrade_gateway_request, string $contentType = self::contentTypes['upgradeGateway'][0])
|
|
{
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayVpcGwV2Gateway';
|
|
$request = $this->upgradeGatewayRequest($zone, $gateway_id, $upgrade_gateway_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 'upgradeGateway'
|
|
*
|
|
* @param string $zone The zone you want to target (required)
|
|
* @param string $gateway_id ID of the gateway to upgrade. (UUID format) (required)
|
|
* @param \OpenAPI\Client\Model\UpgradeGatewayRequest $upgrade_gateway_request (required)
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upgradeGateway'] to see the possible values for this operation
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
* @return \GuzzleHttp\Psr7\Request
|
|
*/
|
|
public function upgradeGatewayRequest($zone, $gateway_id, $upgrade_gateway_request, string $contentType = self::contentTypes['upgradeGateway'][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 upgradeGateway'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'gateway_id' is set
|
|
if ($gateway_id === null || (is_array($gateway_id) && count($gateway_id) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $gateway_id when calling upgradeGateway'
|
|
);
|
|
}
|
|
|
|
// verify the required parameter 'upgrade_gateway_request' is set
|
|
if ($upgrade_gateway_request === null || (is_array($upgrade_gateway_request) && count($upgrade_gateway_request) === 0)) {
|
|
throw new \InvalidArgumentException(
|
|
'Missing the required parameter $upgrade_gateway_request when calling upgradeGateway'
|
|
);
|
|
}
|
|
|
|
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/upgrade';
|
|
$formParams = [];
|
|
$queryParams = [];
|
|
$headerParams = [];
|
|
$httpBody = '';
|
|
$multipart = false;
|
|
|
|
|
|
|
|
// path params
|
|
if ($zone !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'zone' . '}',
|
|
ObjectSerializer::toPathValue($zone),
|
|
$resourcePath
|
|
);
|
|
}
|
|
// path params
|
|
if ($gateway_id !== null) {
|
|
$resourcePath = str_replace(
|
|
'{' . 'gateway_id' . '}',
|
|
ObjectSerializer::toPathValue($gateway_id),
|
|
$resourcePath
|
|
);
|
|
}
|
|
|
|
|
|
$headers = $this->headerSelector->selectHeaders(
|
|
['application/json', ],
|
|
$contentType,
|
|
$multipart
|
|
);
|
|
|
|
// for model (json/xml)
|
|
if (isset($upgrade_gateway_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($upgrade_gateway_request));
|
|
} else {
|
|
$httpBody = $upgrade_gateway_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
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
}
|