1115 lines
54 KiB
PHP
1115 lines
54 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* AllowedIPsApi
|
||
|
|
* 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 fo
|
||
|
|
*
|
||
|
|
* 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;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* AllowedIPsApi Class Doc Comment
|
||
|
|
*
|
||
|
|
* @category Class
|
||
|
|
* @package OpenAPI\Client
|
||
|
|
* @author OpenAPI Generator team
|
||
|
|
* @link https://openapi-generator.tech
|
||
|
|
*/
|
||
|
|
class AllowedIPsApi
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @var ClientInterface
|
||
|
|
*/
|
||
|
|
protected $client;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var Configuration
|
||
|
|
*/
|
||
|
|
protected $config;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var HeaderSelector
|
||
|
|
*/
|
||
|
|
protected $headerSelector;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @var int Host index
|
||
|
|
*/
|
||
|
|
protected $hostIndex;
|
||
|
|
|
||
|
|
/** @var string[] $contentTypes **/
|
||
|
|
public const contentTypes = [
|
||
|
|
'addBastionAllowedIPs' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'deleteBastionAllowedIPs' => [
|
||
|
|
'application/json',
|
||
|
|
],
|
||
|
|
'setBastionAllowedIPs' => [
|
||
|
|
'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 addBastionAllowedIPs
|
||
|
|
*
|
||
|
|
* Add allowed IP range to SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway to add the allowed IP range to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\AddBastionAllowedIPsRequest $add_bastion_allowed_ips_request add_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['addBastionAllowedIPs'] 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\ScalewayVpcGwV2AddBastionAllowedIPsResponse
|
||
|
|
*/
|
||
|
|
public function addBastionAllowedIPs($zone, $gateway_id, $add_bastion_allowed_ips_request, string $contentType = self::contentTypes['addBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->addBastionAllowedIPsWithHttpInfo($zone, $gateway_id, $add_bastion_allowed_ips_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation addBastionAllowedIPsWithHttpInfo
|
||
|
|
*
|
||
|
|
* Add allowed IP range to SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway to add the allowed IP range to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\AddBastionAllowedIPsRequest $add_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['addBastionAllowedIPs'] 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\ScalewayVpcGwV2AddBastionAllowedIPsResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function addBastionAllowedIPsWithHttpInfo($zone, $gateway_id, $add_bastion_allowed_ips_request, string $contentType = self::contentTypes['addBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
$request = $this->addBastionAllowedIPsRequest($zone, $gateway_id, $add_bastion_allowed_ips_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\ScalewayVpcGwV2AddBastionAllowedIPsResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayVpcGwV2AddBastionAllowedIPsResponse' !== '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\ScalewayVpcGwV2AddBastionAllowedIPsResponse', []),
|
||
|
|
$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\ScalewayVpcGwV2AddBastionAllowedIPsResponse';
|
||
|
|
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\ScalewayVpcGwV2AddBastionAllowedIPsResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation addBastionAllowedIPsAsync
|
||
|
|
*
|
||
|
|
* Add allowed IP range to SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway to add the allowed IP range to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\AddBastionAllowedIPsRequest $add_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['addBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function addBastionAllowedIPsAsync($zone, $gateway_id, $add_bastion_allowed_ips_request, string $contentType = self::contentTypes['addBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
return $this->addBastionAllowedIPsAsyncWithHttpInfo($zone, $gateway_id, $add_bastion_allowed_ips_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation addBastionAllowedIPsAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Add allowed IP range to SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway to add the allowed IP range to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\AddBastionAllowedIPsRequest $add_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['addBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function addBastionAllowedIPsAsyncWithHttpInfo($zone, $gateway_id, $add_bastion_allowed_ips_request, string $contentType = self::contentTypes['addBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayVpcGwV2AddBastionAllowedIPsResponse';
|
||
|
|
$request = $this->addBastionAllowedIPsRequest($zone, $gateway_id, $add_bastion_allowed_ips_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 'addBastionAllowedIPs'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway to add the allowed IP range to. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\AddBastionAllowedIPsRequest $add_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['addBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function addBastionAllowedIPsRequest($zone, $gateway_id, $add_bastion_allowed_ips_request, string $contentType = self::contentTypes['addBastionAllowedIPs'][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 addBastionAllowedIPs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 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 addBastionAllowedIPs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'add_bastion_allowed_ips_request' is set
|
||
|
|
if ($add_bastion_allowed_ips_request === null || (is_array($add_bastion_allowed_ips_request) && count($add_bastion_allowed_ips_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $add_bastion_allowed_ips_request when calling addBastionAllowedIPs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/bastion-allowed-ips';
|
||
|
|
$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($add_bastion_allowed_ips_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($add_bastion_allowed_ips_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $add_bastion_allowed_ips_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 deleteBastionAllowedIPs
|
||
|
|
*
|
||
|
|
* Delete allowed IP range from SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to delete the allowed IP range. (required)
|
||
|
|
* @param string $ip_range IP range to delete from SSH bastion's list of allowed IPs. (IP network) (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function deleteBastionAllowedIPs($zone, $gateway_id, $ip_range, string $contentType = self::contentTypes['deleteBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
$this->deleteBastionAllowedIPsWithHttpInfo($zone, $gateway_id, $ip_range, $contentType);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deleteBastionAllowedIPsWithHttpInfo
|
||
|
|
*
|
||
|
|
* Delete allowed IP range from SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to delete the allowed IP range. (required)
|
||
|
|
* @param string $ip_range IP range to delete from SSH bastion's list of allowed IPs. (IP network) (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return array of null, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function deleteBastionAllowedIPsWithHttpInfo($zone, $gateway_id, $ip_range, string $contentType = self::contentTypes['deleteBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
$request = $this->deleteBastionAllowedIPsRequest($zone, $gateway_id, $ip_range, $contentType);
|
||
|
|
|
||
|
|
try {
|
||
|
|
$options = $this->createHttpClientOption();
|
||
|
|
try {
|
||
|
|
$response = $this->client->send($request, $options);
|
||
|
|
} catch (RequestException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
|
||
|
|
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
|
||
|
|
);
|
||
|
|
} catch (ConnectException $e) {
|
||
|
|
throw new ApiException(
|
||
|
|
"[{$e->getCode()}] {$e->getMessage()}",
|
||
|
|
(int) $e->getCode(),
|
||
|
|
null,
|
||
|
|
null
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
|
||
|
|
|
||
|
|
return [null, $statusCode, $response->getHeaders()];
|
||
|
|
|
||
|
|
} catch (ApiException $e) {
|
||
|
|
switch ($e->getCode()) {
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deleteBastionAllowedIPsAsync
|
||
|
|
*
|
||
|
|
* Delete allowed IP range from SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to delete the allowed IP range. (required)
|
||
|
|
* @param string $ip_range IP range to delete from SSH bastion's list of allowed IPs. (IP network) (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function deleteBastionAllowedIPsAsync($zone, $gateway_id, $ip_range, string $contentType = self::contentTypes['deleteBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
return $this->deleteBastionAllowedIPsAsyncWithHttpInfo($zone, $gateway_id, $ip_range, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation deleteBastionAllowedIPsAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Delete allowed IP range from SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to delete the allowed IP range. (required)
|
||
|
|
* @param string $ip_range IP range to delete from SSH bastion's list of allowed IPs. (IP network) (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function deleteBastionAllowedIPsAsyncWithHttpInfo($zone, $gateway_id, $ip_range, string $contentType = self::contentTypes['deleteBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
$returnType = '';
|
||
|
|
$request = $this->deleteBastionAllowedIPsRequest($zone, $gateway_id, $ip_range, $contentType);
|
||
|
|
|
||
|
|
return $this->client
|
||
|
|
->sendAsync($request, $this->createHttpClientOption())
|
||
|
|
->then(
|
||
|
|
function ($response) use ($returnType) {
|
||
|
|
return [null, $response->getStatusCode(), $response->getHeaders()];
|
||
|
|
},
|
||
|
|
function ($exception) {
|
||
|
|
$response = $exception->getResponse();
|
||
|
|
$statusCode = $response->getStatusCode();
|
||
|
|
throw new ApiException(
|
||
|
|
sprintf(
|
||
|
|
'[%d] Error connecting to the API (%s)',
|
||
|
|
$statusCode,
|
||
|
|
$exception->getRequest()->getUri()
|
||
|
|
),
|
||
|
|
$statusCode,
|
||
|
|
$response->getHeaders(),
|
||
|
|
(string) $response->getBody()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create request for operation 'deleteBastionAllowedIPs'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to delete the allowed IP range. (required)
|
||
|
|
* @param string $ip_range IP range to delete from SSH bastion's list of allowed IPs. (IP network) (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function deleteBastionAllowedIPsRequest($zone, $gateway_id, $ip_range, string $contentType = self::contentTypes['deleteBastionAllowedIPs'][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 deleteBastionAllowedIPs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 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 deleteBastionAllowedIPs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'ip_range' is set
|
||
|
|
if ($ip_range === null || (is_array($ip_range) && count($ip_range) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $ip_range when calling deleteBastionAllowedIPs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/bastion-allowed-ips/{ip_range}';
|
||
|
|
$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
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// path params
|
||
|
|
if ($ip_range !== null) {
|
||
|
|
$resourcePath = str_replace(
|
||
|
|
'{' . 'ip_range' . '}',
|
||
|
|
ObjectSerializer::toPathValue($ip_range),
|
||
|
|
$resourcePath
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$headers = $this->headerSelector->selectHeaders(
|
||
|
|
[],
|
||
|
|
$contentType,
|
||
|
|
$multipart
|
||
|
|
);
|
||
|
|
|
||
|
|
// for model (json/xml)
|
||
|
|
if (count($formParams) > 0) {
|
||
|
|
if ($multipart) {
|
||
|
|
$multipartContents = [];
|
||
|
|
foreach ($formParams as $formParamName => $formParamValue) {
|
||
|
|
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
|
||
|
|
foreach ($formParamValueItems as $formParamValueItem) {
|
||
|
|
$multipartContents[] = [
|
||
|
|
'name' => $formParamName,
|
||
|
|
'contents' => $formParamValueItem
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = new MultipartStream($multipartContents);
|
||
|
|
|
||
|
|
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the form parameters
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
|
||
|
|
} else {
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = ObjectSerializer::buildQuery($formParams);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// this endpoint requires API key authentication
|
||
|
|
$apiKey = $this->config->getApiKeyWithPrefix('X-Auth-Token');
|
||
|
|
if ($apiKey !== null) {
|
||
|
|
$headers['X-Auth-Token'] = $apiKey;
|
||
|
|
}
|
||
|
|
|
||
|
|
$defaultHeaders = [];
|
||
|
|
if ($this->config->getUserAgent()) {
|
||
|
|
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||
|
|
}
|
||
|
|
|
||
|
|
$headers = array_merge(
|
||
|
|
$defaultHeaders,
|
||
|
|
$headerParams,
|
||
|
|
$headers
|
||
|
|
);
|
||
|
|
|
||
|
|
$operationHost = $this->config->getHost();
|
||
|
|
$query = ObjectSerializer::buildQuery($queryParams);
|
||
|
|
return new Request(
|
||
|
|
'DELETE',
|
||
|
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
||
|
|
$headers,
|
||
|
|
$httpBody
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation setBastionAllowedIPs
|
||
|
|
*
|
||
|
|
* Set all IP ranges allowed for SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to set the allowed IP range. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetBastionAllowedIPsRequest $set_bastion_allowed_ips_request set_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setBastionAllowedIPs'] 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\ScalewayVpcGwV2SetBastionAllowedIPsResponse
|
||
|
|
*/
|
||
|
|
public function setBastionAllowedIPs($zone, $gateway_id, $set_bastion_allowed_ips_request, string $contentType = self::contentTypes['setBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
list($response) = $this->setBastionAllowedIPsWithHttpInfo($zone, $gateway_id, $set_bastion_allowed_ips_request, $contentType);
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation setBastionAllowedIPsWithHttpInfo
|
||
|
|
*
|
||
|
|
* Set all IP ranges allowed for SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to set the allowed IP range. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetBastionAllowedIPsRequest $set_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setBastionAllowedIPs'] 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\ScalewayVpcGwV2SetBastionAllowedIPsResponse, HTTP status code, HTTP response headers (array of strings)
|
||
|
|
*/
|
||
|
|
public function setBastionAllowedIPsWithHttpInfo($zone, $gateway_id, $set_bastion_allowed_ips_request, string $contentType = self::contentTypes['setBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
$request = $this->setBastionAllowedIPsRequest($zone, $gateway_id, $set_bastion_allowed_ips_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\ScalewayVpcGwV2SetBastionAllowedIPsResponse' === '\SplFileObject') {
|
||
|
|
$content = $response->getBody(); //stream goes to serializer
|
||
|
|
} else {
|
||
|
|
$content = (string) $response->getBody();
|
||
|
|
if ('\OpenAPI\Client\Model\ScalewayVpcGwV2SetBastionAllowedIPsResponse' !== '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\ScalewayVpcGwV2SetBastionAllowedIPsResponse', []),
|
||
|
|
$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\ScalewayVpcGwV2SetBastionAllowedIPsResponse';
|
||
|
|
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\ScalewayVpcGwV2SetBastionAllowedIPsResponse',
|
||
|
|
$e->getResponseHeaders()
|
||
|
|
);
|
||
|
|
$e->setResponseObject($data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
throw $e;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation setBastionAllowedIPsAsync
|
||
|
|
*
|
||
|
|
* Set all IP ranges allowed for SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to set the allowed IP range. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetBastionAllowedIPsRequest $set_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function setBastionAllowedIPsAsync($zone, $gateway_id, $set_bastion_allowed_ips_request, string $contentType = self::contentTypes['setBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
return $this->setBastionAllowedIPsAsyncWithHttpInfo($zone, $gateway_id, $set_bastion_allowed_ips_request, $contentType)
|
||
|
|
->then(
|
||
|
|
function ($response) {
|
||
|
|
return $response[0];
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operation setBastionAllowedIPsAsyncWithHttpInfo
|
||
|
|
*
|
||
|
|
* Set all IP ranges allowed for SSH bastion
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to set the allowed IP range. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetBastionAllowedIPsRequest $set_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Promise\PromiseInterface
|
||
|
|
*/
|
||
|
|
public function setBastionAllowedIPsAsyncWithHttpInfo($zone, $gateway_id, $set_bastion_allowed_ips_request, string $contentType = self::contentTypes['setBastionAllowedIPs'][0])
|
||
|
|
{
|
||
|
|
$returnType = '\OpenAPI\Client\Model\ScalewayVpcGwV2SetBastionAllowedIPsResponse';
|
||
|
|
$request = $this->setBastionAllowedIPsRequest($zone, $gateway_id, $set_bastion_allowed_ips_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 'setBastionAllowedIPs'
|
||
|
|
*
|
||
|
|
* @param string $zone The zone you want to target (required)
|
||
|
|
* @param string $gateway_id ID of the gateway on which to set the allowed IP range. (required)
|
||
|
|
* @param \OpenAPI\Client\Model\SetBastionAllowedIPsRequest $set_bastion_allowed_ips_request (required)
|
||
|
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['setBastionAllowedIPs'] to see the possible values for this operation
|
||
|
|
*
|
||
|
|
* @throws \InvalidArgumentException
|
||
|
|
* @return \GuzzleHttp\Psr7\Request
|
||
|
|
*/
|
||
|
|
public function setBastionAllowedIPsRequest($zone, $gateway_id, $set_bastion_allowed_ips_request, string $contentType = self::contentTypes['setBastionAllowedIPs'][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 setBastionAllowedIPs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 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 setBastionAllowedIPs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// verify the required parameter 'set_bastion_allowed_ips_request' is set
|
||
|
|
if ($set_bastion_allowed_ips_request === null || (is_array($set_bastion_allowed_ips_request) && count($set_bastion_allowed_ips_request) === 0)) {
|
||
|
|
throw new \InvalidArgumentException(
|
||
|
|
'Missing the required parameter $set_bastion_allowed_ips_request when calling setBastionAllowedIPs'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$resourcePath = '/vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/bastion-allowed-ips';
|
||
|
|
$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($set_bastion_allowed_ips_request)) {
|
||
|
|
if (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the body
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_bastion_allowed_ips_request));
|
||
|
|
} else {
|
||
|
|
$httpBody = $set_bastion_allowed_ips_request;
|
||
|
|
}
|
||
|
|
} elseif (count($formParams) > 0) {
|
||
|
|
if ($multipart) {
|
||
|
|
$multipartContents = [];
|
||
|
|
foreach ($formParams as $formParamName => $formParamValue) {
|
||
|
|
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
|
||
|
|
foreach ($formParamValueItems as $formParamValueItem) {
|
||
|
|
$multipartContents[] = [
|
||
|
|
'name' => $formParamName,
|
||
|
|
'contents' => $formParamValueItem
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = new MultipartStream($multipartContents);
|
||
|
|
|
||
|
|
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
|
||
|
|
# if Content-Type contains "application/json", json_encode the form parameters
|
||
|
|
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
|
||
|
|
} else {
|
||
|
|
// for HTTP post (form)
|
||
|
|
$httpBody = ObjectSerializer::buildQuery($formParams);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// this endpoint requires API key authentication
|
||
|
|
$apiKey = $this->config->getApiKeyWithPrefix('X-Auth-Token');
|
||
|
|
if ($apiKey !== null) {
|
||
|
|
$headers['X-Auth-Token'] = $apiKey;
|
||
|
|
}
|
||
|
|
|
||
|
|
$defaultHeaders = [];
|
||
|
|
if ($this->config->getUserAgent()) {
|
||
|
|
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||
|
|
}
|
||
|
|
|
||
|
|
$headers = array_merge(
|
||
|
|
$defaultHeaders,
|
||
|
|
$headerParams,
|
||
|
|
$headers
|
||
|
|
);
|
||
|
|
|
||
|
|
$operationHost = $this->config->getHost();
|
||
|
|
$query = ObjectSerializer::buildQuery($queryParams);
|
||
|
|
return new Request(
|
||
|
|
'PUT',
|
||
|
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
||
|
|
$headers,
|
||
|
|
$httpBody
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 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;
|
||
|
|
}
|
||
|
|
}
|