PHP SDK to use Scaleway Public Gateways APIs https://www.scaleway.com/en/developers/api/public-gateways/
  • PHP 99.9%
  • Shell 0.1%
Find a file
2025-12-19 14:49:14 +01:00
.idea Initial commit 2025-12-19 14:45:32 +01:00
.openapi-generator Initial commit 2025-12-19 14:45:32 +01:00
docs Initial commit 2025-12-19 14:45:32 +01:00
lib Initial commit 2025-12-19 14:45:32 +01:00
test Initial commit 2025-12-19 14:45:32 +01:00
.gitignore Initial commit 2025-12-19 14:45:32 +01:00
.openapi-generator-ignore Initial commit 2025-12-19 14:45:32 +01:00
.php-cs-fixer.dist.php Initial commit 2025-12-19 14:45:32 +01:00
.travis.yml Initial commit 2025-12-19 14:45:32 +01:00
composer.json Updates project name and desc. 2025-12-19 14:49:14 +01:00
git_push.sh Initial commit 2025-12-19 14:45:32 +01:00
phpunit.xml.dist Initial commit 2025-12-19 14:45:32 +01:00
README.md Initial commit 2025-12-19 14:45:32 +01:00
scaleway.vpc_gw.v2.Api.yml Initial commit 2025-12-19 14:45:32 +01:00

OpenAPIClient-php

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. (switchcolumn)

Concepts

Refer to our dedicated concepts page 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.

    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:

    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.

    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.

    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 documentation to learn how to do so. Ensure you retain the ID of the Private Network.

    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 documentation below for full details of all possible parameters.

  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.

    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">

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 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.

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:

Installation & Usage

Requirements

PHP 7.4 and later. Should also work with PHP 8.0.

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
    }
  ],
  "require": {
    "GIT_USER_ID/GIT_REPO_ID": "*@dev"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

<?php
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');



// Configure API key authorization: scaleway
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('X-Auth-Token', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-Auth-Token', 'Bearer');


$apiInstance = new OpenAPI\Client\Api\AllowedIPsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$zone = 'zone_example'; // string | The zone you want to target
$gateway_id = 'gateway_id_example'; // string | ID of the gateway to add the allowed IP range to.
$add_bastion_allowed_ips_request = new \OpenAPI\Client\Model\AddBastionAllowedIPsRequest(); // \OpenAPI\Client\Model\AddBastionAllowedIPsRequest

try {
    $result = $apiInstance->addBastionAllowedIPs($zone, $gateway_id, $add_bastion_allowed_ips_request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AllowedIPsApi->addBastionAllowedIPs: ', $e->getMessage(), PHP_EOL;
}

API Endpoints

All URIs are relative to https://api.scaleway.com

Class Method HTTP request Description
AllowedIPsApi addBastionAllowedIPs POST /vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/bastion-allowed-ips Add allowed IP range to SSH bastion
AllowedIPsApi deleteBastionAllowedIPs DELETE /vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/bastion-allowed-ips/{ip_range} Delete allowed IP range from SSH bastion
AllowedIPsApi setBastionAllowedIPs PUT /vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/bastion-allowed-ips Set all IP ranges allowed for SSH bastion
GatewayNetworksApi createGatewayNetwork POST /vpc-gw/v2/zones/{zone}/gateway-networks Attach a Public Gateway to a Private Network
GatewayNetworksApi deleteGatewayNetwork DELETE /vpc-gw/v2/zones/{zone}/gateway-networks/{gateway_network_id} Detach a Public Gateway from a Private Network
GatewayNetworksApi getGatewayNetwork GET /vpc-gw/v2/zones/{zone}/gateway-networks/{gateway_network_id} Get a Public Gateway connection to a Private Network
GatewayNetworksApi listGatewayNetworks GET /vpc-gw/v2/zones/{zone}/gateway-networks List Public Gateway connections to Private Networks
GatewayNetworksApi updateGatewayNetwork PATCH /vpc-gw/v2/zones/{zone}/gateway-networks/{gateway_network_id} Update a Public Gateway's connection to a Private Network
GatewayTypesApi listGatewayTypes GET /vpc-gw/v2/zones/{zone}/gateway-types List Public Gateway types
GatewaysApi createGateway POST /vpc-gw/v2/zones/{zone}/gateways Create a Public Gateway
GatewaysApi deleteGateway DELETE /vpc-gw/v2/zones/{zone}/gateways/{gateway_id} Delete a Public Gateway
GatewaysApi getGateway GET /vpc-gw/v2/zones/{zone}/gateways/{gateway_id} Get a Public Gateway
GatewaysApi listGateways GET /vpc-gw/v2/zones/{zone}/gateways List Public Gateways
GatewaysApi refreshSSHKeys POST /vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/refresh-ssh-keys Refresh a Public Gateway's SSH keys
GatewaysApi updateGateway PATCH /vpc-gw/v2/zones/{zone}/gateways/{gateway_id} Update a Public Gateway
GatewaysApi upgradeGateway POST /vpc-gw/v2/zones/{zone}/gateways/{gateway_id}/upgrade Upgrade a Public Gateway to the latest version and/or to a different commercial offer type
IPsApi createIP POST /vpc-gw/v2/zones/{zone}/ips Reserve an IP
IPsApi deleteIP DELETE /vpc-gw/v2/zones/{zone}/ips/{ip_id} Delete an IP
IPsApi getIP GET /vpc-gw/v2/zones/{zone}/ips/{ip_id} Get an IP
IPsApi listIPs GET /vpc-gw/v2/zones/{zone}/ips List IPs
IPsApi updateIP PATCH /vpc-gw/v2/zones/{zone}/ips/{ip_id} Update an IP
PATRulesApi createPatRule POST /vpc-gw/v2/zones/{zone}/pat-rules Create a PAT rule
PATRulesApi deletePatRule DELETE /vpc-gw/v2/zones/{zone}/pat-rules/{pat_rule_id} Delete a PAT rule
PATRulesApi getPatRule GET /vpc-gw/v2/zones/{zone}/pat-rules/{pat_rule_id} Get a PAT rule
PATRulesApi listPatRules GET /vpc-gw/v2/zones/{zone}/pat-rules List PAT rules
PATRulesApi setPatRules PUT /vpc-gw/v2/zones/{zone}/pat-rules Set all PAT rules
PATRulesApi updatePatRule PATCH /vpc-gw/v2/zones/{zone}/pat-rules/{pat_rule_id} Update a PAT rule

Models

Authorization

Authentication schemes defined for the API:

scaleway

  • Type: API key
  • API key parameter name: X-Auth-Token
  • Location: HTTP header

Tests

To run the tests, use:

composer install
vendor/bin/phpunit

Author

About this package

This PHP package is automatically generated by the OpenAPI Generator project:

  • API version: v2
    • Generator version: 7.11.0
  • Build package: org.openapitools.codegen.languages.PhpClientCodegen