1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081
|
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
// Package vpcgw provides methods and message types of the vpcgw v2 API.
package vpcgw
import (
"bytes"
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
"strings"
"time"
"github.com/scaleway/scaleway-sdk-go/errors"
"github.com/scaleway/scaleway-sdk-go/marshaler"
"github.com/scaleway/scaleway-sdk-go/namegenerator"
"github.com/scaleway/scaleway-sdk-go/parameter"
"github.com/scaleway/scaleway-sdk-go/scw"
)
// always import dependencies
var (
_ fmt.Stringer
_ json.Unmarshaler
_ url.URL
_ net.IP
_ http.Header
_ bytes.Reader
_ time.Time
_ = strings.Join
_ scw.ScalewayRequest
_ marshaler.Duration
_ scw.File
_ = parameter.AddToQuery
_ = namegenerator.GetRandomName
)
type GatewayNetworkStatus string
const (
GatewayNetworkStatusUnknownStatus = GatewayNetworkStatus("unknown_status")
GatewayNetworkStatusCreated = GatewayNetworkStatus("created")
GatewayNetworkStatusAttaching = GatewayNetworkStatus("attaching")
GatewayNetworkStatusConfiguring = GatewayNetworkStatus("configuring")
GatewayNetworkStatusReady = GatewayNetworkStatus("ready")
GatewayNetworkStatusDetaching = GatewayNetworkStatus("detaching")
)
func (enum GatewayNetworkStatus) String() string {
if enum == "" {
// return default value if empty
return "unknown_status"
}
return string(enum)
}
func (enum GatewayNetworkStatus) Values() []GatewayNetworkStatus {
return []GatewayNetworkStatus{
"unknown_status",
"created",
"attaching",
"configuring",
"ready",
"detaching",
}
}
func (enum GatewayNetworkStatus) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *GatewayNetworkStatus) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = GatewayNetworkStatus(GatewayNetworkStatus(tmp).String())
return nil
}
type GatewayStatus string
const (
GatewayStatusUnknownStatus = GatewayStatus("unknown_status")
GatewayStatusStopped = GatewayStatus("stopped")
GatewayStatusAllocating = GatewayStatus("allocating")
GatewayStatusConfiguring = GatewayStatus("configuring")
GatewayStatusRunning = GatewayStatus("running")
GatewayStatusStopping = GatewayStatus("stopping")
GatewayStatusFailed = GatewayStatus("failed")
GatewayStatusDeleting = GatewayStatus("deleting")
GatewayStatusLocked = GatewayStatus("locked")
)
func (enum GatewayStatus) String() string {
if enum == "" {
// return default value if empty
return "unknown_status"
}
return string(enum)
}
func (enum GatewayStatus) Values() []GatewayStatus {
return []GatewayStatus{
"unknown_status",
"stopped",
"allocating",
"configuring",
"running",
"stopping",
"failed",
"deleting",
"locked",
}
}
func (enum GatewayStatus) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *GatewayStatus) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = GatewayStatus(GatewayStatus(tmp).String())
return nil
}
type ListGatewayNetworksRequestOrderBy string
const (
ListGatewayNetworksRequestOrderByCreatedAtAsc = ListGatewayNetworksRequestOrderBy("created_at_asc")
ListGatewayNetworksRequestOrderByCreatedAtDesc = ListGatewayNetworksRequestOrderBy("created_at_desc")
ListGatewayNetworksRequestOrderByStatusAsc = ListGatewayNetworksRequestOrderBy("status_asc")
ListGatewayNetworksRequestOrderByStatusDesc = ListGatewayNetworksRequestOrderBy("status_desc")
)
func (enum ListGatewayNetworksRequestOrderBy) String() string {
if enum == "" {
// return default value if empty
return "created_at_asc"
}
return string(enum)
}
func (enum ListGatewayNetworksRequestOrderBy) Values() []ListGatewayNetworksRequestOrderBy {
return []ListGatewayNetworksRequestOrderBy{
"created_at_asc",
"created_at_desc",
"status_asc",
"status_desc",
}
}
func (enum ListGatewayNetworksRequestOrderBy) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *ListGatewayNetworksRequestOrderBy) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = ListGatewayNetworksRequestOrderBy(ListGatewayNetworksRequestOrderBy(tmp).String())
return nil
}
type ListGatewaysRequestOrderBy string
const (
ListGatewaysRequestOrderByCreatedAtAsc = ListGatewaysRequestOrderBy("created_at_asc")
ListGatewaysRequestOrderByCreatedAtDesc = ListGatewaysRequestOrderBy("created_at_desc")
ListGatewaysRequestOrderByNameAsc = ListGatewaysRequestOrderBy("name_asc")
ListGatewaysRequestOrderByNameDesc = ListGatewaysRequestOrderBy("name_desc")
ListGatewaysRequestOrderByTypeAsc = ListGatewaysRequestOrderBy("type_asc")
ListGatewaysRequestOrderByTypeDesc = ListGatewaysRequestOrderBy("type_desc")
ListGatewaysRequestOrderByStatusAsc = ListGatewaysRequestOrderBy("status_asc")
ListGatewaysRequestOrderByStatusDesc = ListGatewaysRequestOrderBy("status_desc")
)
func (enum ListGatewaysRequestOrderBy) String() string {
if enum == "" {
// return default value if empty
return "created_at_asc"
}
return string(enum)
}
func (enum ListGatewaysRequestOrderBy) Values() []ListGatewaysRequestOrderBy {
return []ListGatewaysRequestOrderBy{
"created_at_asc",
"created_at_desc",
"name_asc",
"name_desc",
"type_asc",
"type_desc",
"status_asc",
"status_desc",
}
}
func (enum ListGatewaysRequestOrderBy) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *ListGatewaysRequestOrderBy) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = ListGatewaysRequestOrderBy(ListGatewaysRequestOrderBy(tmp).String())
return nil
}
type ListIPsRequestOrderBy string
const (
ListIPsRequestOrderByCreatedAtAsc = ListIPsRequestOrderBy("created_at_asc")
ListIPsRequestOrderByCreatedAtDesc = ListIPsRequestOrderBy("created_at_desc")
ListIPsRequestOrderByAddressAsc = ListIPsRequestOrderBy("address_asc")
ListIPsRequestOrderByAddressDesc = ListIPsRequestOrderBy("address_desc")
ListIPsRequestOrderByReverseAsc = ListIPsRequestOrderBy("reverse_asc")
ListIPsRequestOrderByReverseDesc = ListIPsRequestOrderBy("reverse_desc")
)
func (enum ListIPsRequestOrderBy) String() string {
if enum == "" {
// return default value if empty
return "created_at_asc"
}
return string(enum)
}
func (enum ListIPsRequestOrderBy) Values() []ListIPsRequestOrderBy {
return []ListIPsRequestOrderBy{
"created_at_asc",
"created_at_desc",
"address_asc",
"address_desc",
"reverse_asc",
"reverse_desc",
}
}
func (enum ListIPsRequestOrderBy) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *ListIPsRequestOrderBy) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = ListIPsRequestOrderBy(ListIPsRequestOrderBy(tmp).String())
return nil
}
type ListPatRulesRequestOrderBy string
const (
ListPatRulesRequestOrderByCreatedAtAsc = ListPatRulesRequestOrderBy("created_at_asc")
ListPatRulesRequestOrderByCreatedAtDesc = ListPatRulesRequestOrderBy("created_at_desc")
ListPatRulesRequestOrderByPublicPortAsc = ListPatRulesRequestOrderBy("public_port_asc")
ListPatRulesRequestOrderByPublicPortDesc = ListPatRulesRequestOrderBy("public_port_desc")
)
func (enum ListPatRulesRequestOrderBy) String() string {
if enum == "" {
// return default value if empty
return "created_at_asc"
}
return string(enum)
}
func (enum ListPatRulesRequestOrderBy) Values() []ListPatRulesRequestOrderBy {
return []ListPatRulesRequestOrderBy{
"created_at_asc",
"created_at_desc",
"public_port_asc",
"public_port_desc",
}
}
func (enum ListPatRulesRequestOrderBy) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *ListPatRulesRequestOrderBy) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = ListPatRulesRequestOrderBy(ListPatRulesRequestOrderBy(tmp).String())
return nil
}
type PatRuleProtocol string
const (
PatRuleProtocolUnknownProtocol = PatRuleProtocol("unknown_protocol")
PatRuleProtocolBoth = PatRuleProtocol("both")
PatRuleProtocolTCP = PatRuleProtocol("tcp")
PatRuleProtocolUDP = PatRuleProtocol("udp")
)
func (enum PatRuleProtocol) String() string {
if enum == "" {
// return default value if empty
return "unknown_protocol"
}
return string(enum)
}
func (enum PatRuleProtocol) Values() []PatRuleProtocol {
return []PatRuleProtocol{
"unknown_protocol",
"both",
"tcp",
"udp",
}
}
func (enum PatRuleProtocol) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *PatRuleProtocol) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = PatRuleProtocol(PatRuleProtocol(tmp).String())
return nil
}
// GatewayNetwork: gateway network.
type GatewayNetwork struct {
// ID: ID of the Public Gateway-Private Network connection.
ID string `json:"id"`
// CreatedAt: connection creation date.
CreatedAt *time.Time `json:"created_at"`
// UpdatedAt: connection last modification date.
UpdatedAt *time.Time `json:"updated_at"`
// GatewayID: ID of the connected Public Gateway.
GatewayID string `json:"gateway_id"`
// PrivateNetworkID: ID of the connected Private Network.
PrivateNetworkID string `json:"private_network_id"`
// MacAddress: mAC address of the gateway in the Private Network (if the gateway is up and running).
MacAddress *string `json:"mac_address"`
// MasqueradeEnabled: defines whether the gateway masquerades traffic for this Private Network (Dynamic NAT).
MasqueradeEnabled bool `json:"masquerade_enabled"`
// Status: current status of the Public Gateway's connection to the Private Network.
// Default value: unknown_status
Status GatewayNetworkStatus `json:"status"`
// PushDefaultRoute: enabling the default route also enables masquerading.
PushDefaultRoute bool `json:"push_default_route"`
// IpamIPID: use this IPAM-booked IP ID as the Gateway's IP in this Private Network.
IpamIPID string `json:"ipam_ip_id"`
// Zone: zone of the GatewayNetwork connection.
Zone scw.Zone `json:"zone"`
}
// IP: ip.
type IP struct {
// ID: IP address ID.
ID string `json:"id"`
// OrganizationID: owning Organization.
OrganizationID string `json:"organization_id"`
// ProjectID: owning Project.
ProjectID string `json:"project_id"`
// CreatedAt: IP address creation date.
CreatedAt *time.Time `json:"created_at"`
// UpdatedAt: IP address last modification date.
UpdatedAt *time.Time `json:"updated_at"`
// Tags: tags associated with the IP address.
Tags []string `json:"tags"`
// Address: the IP address itself.
Address net.IP `json:"address"`
// Reverse: reverse domain name for the IP address.
Reverse *string `json:"reverse"`
// GatewayID: public Gateway associated with the IP address.
GatewayID *string `json:"gateway_id"`
// Zone: zone of the IP address.
Zone scw.Zone `json:"zone"`
}
// GatewayType: gateway type.
type GatewayType struct {
// Name: public Gateway type name.
Name string `json:"name"`
// Bandwidth: bandwidth, in bps, of the Public Gateway. This is the public bandwidth to the outer Internet, and the internal bandwidth to each connected Private Networks.
Bandwidth uint64 `json:"bandwidth"`
// Zone: zone the Public Gateway type is available in.
Zone scw.Zone `json:"zone"`
}
// Gateway: gateway.
type Gateway struct {
// ID: ID of the gateway.
ID string `json:"id"`
// OrganizationID: owning Organization.
OrganizationID string `json:"organization_id"`
// ProjectID: owning Project.
ProjectID string `json:"project_id"`
// CreatedAt: gateway creation date.
CreatedAt *time.Time `json:"created_at"`
// UpdatedAt: gateway last modification date.
UpdatedAt *time.Time `json:"updated_at"`
// Type: gateway type name (commercial offer).
Type string `json:"type"`
// Bandwidth: bandwidth available of the gateway.
Bandwidth uint64 `json:"bandwidth"`
// Status: current status of the gateway.
// Default value: unknown_status
Status GatewayStatus `json:"status"`
// Name: name of the gateway.
Name string `json:"name"`
// Tags: tags associated with the gateway.
Tags []string `json:"tags"`
// IPv4: public IPv4 address of the gateway.
IPv4 *IP `json:"ipv4"`
// GatewayNetworks: gatewayNetwork objects attached to the gateway (each one represents a connection to a Private Network).
GatewayNetworks []*GatewayNetwork `json:"gateway_networks"`
// Version: version of the running gateway software.
Version *string `json:"version"`
// CanUpgradeTo: newly available gateway software version that can be updated to.
CanUpgradeTo *string `json:"can_upgrade_to"`
// BastionEnabled: defines whether SSH bastion is enabled on the gateway.
BastionEnabled bool `json:"bastion_enabled"`
// BastionPort: port of the SSH bastion.
BastionPort uint32 `json:"bastion_port"`
// SMTPEnabled: defines whether SMTP traffic is allowed to pass through the gateway.
SMTPEnabled bool `json:"smtp_enabled"`
// IsLegacy: defines whether the gateway uses non-IPAM IP configurations.
IsLegacy bool `json:"is_legacy"`
// BastionAllowedIPs: ranges of IP addresses allowed to connect to the gateway's SSH bastion.
BastionAllowedIPs []scw.IPNet `json:"bastion_allowed_ips"`
// Zone: zone of the gateway.
Zone scw.Zone `json:"zone"`
}
// PatRule: pat rule.
type PatRule struct {
// ID: pAT rule ID.
ID string `json:"id"`
// GatewayID: gateway the PAT rule applies to.
GatewayID string `json:"gateway_id"`
// CreatedAt: pAT rule creation date.
CreatedAt *time.Time `json:"created_at"`
// UpdatedAt: pAT rule last modification date.
UpdatedAt *time.Time `json:"updated_at"`
// PublicPort: public port to listen on.
PublicPort uint32 `json:"public_port"`
// PrivateIP: private IP address to forward data to.
PrivateIP net.IP `json:"private_ip"`
// PrivatePort: private port to translate to.
PrivatePort uint32 `json:"private_port"`
// Protocol: protocol the rule applies to.
// Default value: unknown_protocol
Protocol PatRuleProtocol `json:"protocol"`
// Zone: zone of the PAT rule.
Zone scw.Zone `json:"zone"`
}
// SetPatRulesRequestRule: set pat rules request rule.
type SetPatRulesRequestRule struct {
// PublicPort: public port to listen on. Uniquely identifies the rule, and a matching rule will be updated with the new parameters.
PublicPort uint32 `json:"public_port"`
// PrivateIP: private IP to forward data to.
PrivateIP net.IP `json:"private_ip"`
// PrivatePort: private port to translate to.
PrivatePort uint32 `json:"private_port"`
// Protocol: protocol the rule should apply to.
// Default value: unknown_protocol
Protocol PatRuleProtocol `json:"protocol"`
}
// AddBastionAllowedIPsRequest: add bastion allowed i ps request.
type AddBastionAllowedIPsRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the gateway to add the allowed IP range to.
GatewayID string `json:"-"`
// IPRange: IP range allowed to connect to the SSH bastion.
IPRange scw.IPNet `json:"ip_range"`
}
// AddBastionAllowedIPsResponse: add bastion allowed i ps response.
type AddBastionAllowedIPsResponse struct {
// IPRanges: ranges of IP addresses allowed to connect to the gateway's SSH bastion.
IPRanges []scw.IPNet `json:"ip_ranges"`
}
// CreateGatewayNetworkRequest: create gateway network request.
type CreateGatewayNetworkRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: public Gateway to connect.
GatewayID string `json:"gateway_id"`
// PrivateNetworkID: private Network to connect.
PrivateNetworkID string `json:"private_network_id"`
// EnableMasquerade: defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork.
EnableMasquerade bool `json:"enable_masquerade"`
// PushDefaultRoute: enabling the default route also enables masquerading.
PushDefaultRoute bool `json:"push_default_route"`
// IpamIPID: use this IPAM-booked IP ID as the Gateway's IP in this Private Network.
IpamIPID *string `json:"ipam_ip_id,omitempty"`
}
// CreateGatewayRequest: create gateway request.
type CreateGatewayRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// ProjectID: scaleway Project to create the gateway in.
ProjectID string `json:"project_id"`
// Name: name for the gateway.
Name string `json:"name"`
// Tags: tags for the gateway.
Tags []string `json:"tags"`
// Type: gateway type (commercial offer type).
Type string `json:"type"`
// IPID: existing IP address to attach to the gateway.
IPID *string `json:"ip_id,omitempty"`
// EnableSMTP: defines whether SMTP traffic should be allowed pass through the gateway.
EnableSMTP bool `json:"enable_smtp"`
// EnableBastion: defines whether SSH bastion should be enabled the gateway.
EnableBastion bool `json:"enable_bastion"`
// BastionPort: port of the SSH bastion.
BastionPort *uint32 `json:"bastion_port,omitempty"`
}
// CreateIPRequest: create ip request.
type CreateIPRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// ProjectID: project to create the IP address in.
ProjectID string `json:"project_id"`
// Tags: tags to give to the IP address.
Tags []string `json:"tags"`
}
// CreatePatRuleRequest: create pat rule request.
type CreatePatRuleRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the Gateway on which to create the rule.
GatewayID string `json:"gateway_id"`
// PublicPort: public port to listen on.
PublicPort uint32 `json:"public_port"`
// PrivateIP: private IP to forward data to.
PrivateIP net.IP `json:"private_ip"`
// PrivatePort: private port to translate to.
PrivatePort uint32 `json:"private_port"`
// Protocol: protocol the rule should apply to.
// Default value: unknown_protocol
Protocol PatRuleProtocol `json:"protocol"`
}
// DeleteBastionAllowedIPsRequest: delete bastion allowed i ps request.
type DeleteBastionAllowedIPsRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the gateway on which to delete the allowed IP range.
GatewayID string `json:"-"`
// IPRange: IP range to delete from SSH bastion's list of allowed IPs.
IPRange scw.IPNet `json:"-"`
}
// DeleteGatewayNetworkRequest: delete gateway network request.
type DeleteGatewayNetworkRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayNetworkID: ID of the GatewayNetwork to delete.
GatewayNetworkID string `json:"-"`
}
// DeleteGatewayRequest: delete gateway request.
type DeleteGatewayRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the gateway to delete.
GatewayID string `json:"-"`
// DeleteIP: defines whether the PGW's IP should be deleted.
DeleteIP bool `json:"delete_ip"`
}
// DeleteIPRequest: delete ip request.
type DeleteIPRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// IPID: ID of the IP address to delete.
IPID string `json:"-"`
}
// DeletePatRuleRequest: delete pat rule request.
type DeletePatRuleRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// PatRuleID: ID of the PAT rule to delete.
PatRuleID string `json:"-"`
}
// GetGatewayNetworkRequest: get gateway network request.
type GetGatewayNetworkRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayNetworkID: ID of the GatewayNetwork to fetch.
GatewayNetworkID string `json:"-"`
}
// GetGatewayRequest: get gateway request.
type GetGatewayRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the gateway to fetch.
GatewayID string `json:"-"`
}
// GetIPRequest: get ip request.
type GetIPRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// IPID: ID of the IP address to get.
IPID string `json:"-"`
}
// GetPatRuleRequest: get pat rule request.
type GetPatRuleRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// PatRuleID: ID of the PAT rule to get.
PatRuleID string `json:"-"`
}
// ListGatewayNetworksRequest: list gateway networks request.
type ListGatewayNetworksRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// OrderBy: order in which to return results.
// Default value: created_at_asc
OrderBy ListGatewayNetworksRequestOrderBy `json:"-"`
// Page: page number.
Page *int32 `json:"-"`
// PageSize: gatewayNetworks per page.
PageSize *uint32 `json:"-"`
// Status: filter for GatewayNetworks with these status. Use `unknown` to include all statuses.
Status []GatewayNetworkStatus `json:"-"`
// GatewayIDs: filter for GatewayNetworks connected to these gateways.
GatewayIDs []string `json:"-"`
// PrivateNetworkIDs: filter for GatewayNetworks connected to these Private Networks.
PrivateNetworkIDs []string `json:"-"`
// MasqueradeEnabled: filter for GatewayNetworks with this `enable_masquerade` setting.
MasqueradeEnabled *bool `json:"-"`
}
// ListGatewayNetworksResponse: list gateway networks response.
type ListGatewayNetworksResponse struct {
// GatewayNetworks: gatewayNetworks on this page.
GatewayNetworks []*GatewayNetwork `json:"gateway_networks"`
// TotalCount: total GatewayNetworks count matching the filter.
TotalCount uint64 `json:"total_count"`
}
// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListGatewayNetworksResponse) UnsafeGetTotalCount() uint64 {
return r.TotalCount
}
// UnsafeAppend should not be used
// Internal usage only
func (r *ListGatewayNetworksResponse) UnsafeAppend(res interface{}) (uint64, error) {
results, ok := res.(*ListGatewayNetworksResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}
r.GatewayNetworks = append(r.GatewayNetworks, results.GatewayNetworks...)
r.TotalCount += uint64(len(results.GatewayNetworks))
return uint64(len(results.GatewayNetworks)), nil
}
// ListGatewayTypesRequest: list gateway types request.
type ListGatewayTypesRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
}
// ListGatewayTypesResponse: list gateway types response.
type ListGatewayTypesResponse struct {
// Types: available types of Public Gateway.
Types []*GatewayType `json:"types"`
}
// ListGatewaysRequest: list gateways request.
type ListGatewaysRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// OrderBy: order in which to return results.
// Default value: created_at_asc
OrderBy ListGatewaysRequestOrderBy `json:"-"`
// Page: page number to return.
Page *int32 `json:"-"`
// PageSize: gateways per page.
PageSize *uint32 `json:"-"`
// OrganizationID: include only gateways in this Organization.
OrganizationID *string `json:"-"`
// ProjectID: include only gateways in this Project.
ProjectID *string `json:"-"`
// Name: filter for gateways which have this search term in their name.
Name *string `json:"-"`
// Tags: filter for gateways with these tags.
Tags []string `json:"-"`
// Types: filter for gateways of these types.
Types []string `json:"-"`
// Status: filter for gateways with these status. Use `unknown` to include all statuses.
Status []GatewayStatus `json:"-"`
// PrivateNetworkIDs: filter for gateways attached to these Private Networks.
PrivateNetworkIDs []string `json:"-"`
// IncludeLegacy: include also legacy gateways.
IncludeLegacy *bool `json:"-"`
}
// ListGatewaysResponse: list gateways response.
type ListGatewaysResponse struct {
// Gateways: gateways on this page.
Gateways []*Gateway `json:"gateways"`
// TotalCount: total count of gateways matching the filter.
TotalCount uint64 `json:"total_count"`
}
// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListGatewaysResponse) UnsafeGetTotalCount() uint64 {
return r.TotalCount
}
// UnsafeAppend should not be used
// Internal usage only
func (r *ListGatewaysResponse) UnsafeAppend(res interface{}) (uint64, error) {
results, ok := res.(*ListGatewaysResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}
r.Gateways = append(r.Gateways, results.Gateways...)
r.TotalCount += uint64(len(results.Gateways))
return uint64(len(results.Gateways)), nil
}
// ListIPsRequest: list i ps request.
type ListIPsRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// OrderBy: order in which to return results.
// Default value: created_at_asc
OrderBy ListIPsRequestOrderBy `json:"-"`
// Page: page number.
Page *int32 `json:"-"`
// PageSize: IP addresses per page.
PageSize *uint32 `json:"-"`
// OrganizationID: include only gateways in this Organization.
OrganizationID *string `json:"-"`
// ProjectID: filter for IP addresses in this Project.
ProjectID *string `json:"-"`
// Tags: filter for IP addresses with these tags.
Tags []string `json:"-"`
// Reverse: filter for IP addresses that have a reverse containing this string.
Reverse *string `json:"-"`
// IsFree: filter based on whether the IP is attached to a gateway or not.
IsFree *bool `json:"-"`
}
// ListIPsResponse: list i ps response.
type ListIPsResponse struct {
// IPs: IP addresses on this page.
IPs []*IP `json:"ips"`
// TotalCount: total count of IP addresses matching the filter.
TotalCount uint64 `json:"total_count"`
}
// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListIPsResponse) UnsafeGetTotalCount() uint64 {
return r.TotalCount
}
// UnsafeAppend should not be used
// Internal usage only
func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint64, error) {
results, ok := res.(*ListIPsResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}
r.IPs = append(r.IPs, results.IPs...)
r.TotalCount += uint64(len(results.IPs))
return uint64(len(results.IPs)), nil
}
// ListPatRulesRequest: list pat rules request.
type ListPatRulesRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// OrderBy: order in which to return results.
// Default value: created_at_asc
OrderBy ListPatRulesRequestOrderBy `json:"-"`
// Page: page number.
Page *int32 `json:"-"`
// PageSize: pAT rules per page.
PageSize *uint32 `json:"-"`
// GatewayIDs: filter for PAT rules on these gateways.
GatewayIDs []string `json:"-"`
// PrivateIPs: filter for PAT rules targeting these private ips.
PrivateIPs []string `json:"-"`
// Protocol: filter for PAT rules with this protocol.
// Default value: unknown_protocol
Protocol PatRuleProtocol `json:"-"`
}
// ListPatRulesResponse: list pat rules response.
type ListPatRulesResponse struct {
// PatRules: array of PAT rules matching the filter.
PatRules []*PatRule `json:"pat_rules"`
// TotalCount: total count of PAT rules matching the filter.
TotalCount uint64 `json:"total_count"`
}
// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListPatRulesResponse) UnsafeGetTotalCount() uint64 {
return r.TotalCount
}
// UnsafeAppend should not be used
// Internal usage only
func (r *ListPatRulesResponse) UnsafeAppend(res interface{}) (uint64, error) {
results, ok := res.(*ListPatRulesResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}
r.PatRules = append(r.PatRules, results.PatRules...)
r.TotalCount += uint64(len(results.PatRules))
return uint64(len(results.PatRules)), nil
}
// RefreshSSHKeysRequest: refresh ssh keys request.
type RefreshSSHKeysRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the gateway to refresh SSH keys on.
GatewayID string `json:"-"`
}
// SetBastionAllowedIPsRequest: set bastion allowed i ps request.
type SetBastionAllowedIPsRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the gateway on which to set the allowed IP range.
GatewayID string `json:"-"`
// IPRanges: new list of IP ranges (each range in CIDR notation) allowed to connect to the SSH bastion.
IPRanges []string `json:"ip_ranges"`
}
// SetBastionAllowedIPsResponse: set bastion allowed i ps response.
type SetBastionAllowedIPsResponse struct {
// IPRanges: ranges of IP addresses allowed to connect to the gateway's SSH bastion.
IPRanges []scw.IPNet `json:"ip_ranges"`
}
// SetPatRulesRequest: set pat rules request.
type SetPatRulesRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the gateway on which to set the PAT rules.
GatewayID string `json:"gateway_id"`
// PatRules: new list of PAT rules.
PatRules []*SetPatRulesRequestRule `json:"pat_rules"`
}
// SetPatRulesResponse: set pat rules response.
type SetPatRulesResponse struct {
// PatRules: list of PAT rules.
PatRules []*PatRule `json:"pat_rules"`
}
// UpdateGatewayNetworkRequest: update gateway network request.
type UpdateGatewayNetworkRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayNetworkID: ID of the GatewayNetwork to update.
GatewayNetworkID string `json:"-"`
// EnableMasquerade: defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork.
EnableMasquerade *bool `json:"enable_masquerade,omitempty"`
// PushDefaultRoute: enabling the default route also enables masquerading.
PushDefaultRoute *bool `json:"push_default_route,omitempty"`
// IpamIPID: use this IPAM-booked IP ID as the Gateway's IP in this Private Network.
IpamIPID *string `json:"ipam_ip_id,omitempty"`
}
// UpdateGatewayRequest: update gateway request.
type UpdateGatewayRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the gateway to update.
GatewayID string `json:"-"`
// Name: name for the gateway.
Name *string `json:"name,omitempty"`
// Tags: tags for the gateway.
Tags *[]string `json:"tags,omitempty"`
// EnableBastion: defines whether SSH bastion should be enabled the gateway.
EnableBastion *bool `json:"enable_bastion,omitempty"`
// BastionPort: port of the SSH bastion.
BastionPort *uint32 `json:"bastion_port,omitempty"`
// EnableSMTP: defines whether SMTP traffic should be allowed to pass through the gateway.
EnableSMTP *bool `json:"enable_smtp,omitempty"`
}
// UpdateIPRequest: update ip request.
type UpdateIPRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// IPID: ID of the IP address to update.
IPID string `json:"-"`
// Tags: tags to give to the IP address.
Tags *[]string `json:"tags,omitempty"`
// Reverse: reverse to set on the address. Empty string to unset.
Reverse *string `json:"reverse,omitempty"`
// GatewayID: gateway to attach the IP address to. Empty string to detach.
GatewayID *string `json:"gateway_id,omitempty"`
}
// UpdatePatRuleRequest: update pat rule request.
type UpdatePatRuleRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// PatRuleID: ID of the PAT rule to update.
PatRuleID string `json:"-"`
// PublicPort: public port to listen on.
PublicPort *uint32 `json:"public_port,omitempty"`
// PrivateIP: private IP to forward data to.
PrivateIP *net.IP `json:"private_ip,omitempty"`
// PrivatePort: private port to translate to.
PrivatePort *uint32 `json:"private_port,omitempty"`
// Protocol: protocol the rule should apply to.
// Default value: unknown_protocol
Protocol PatRuleProtocol `json:"protocol"`
}
// UpgradeGatewayRequest: upgrade gateway request.
type UpgradeGatewayRequest struct {
// Zone: zone to target. If none is passed will use default zone from the config.
Zone scw.Zone `json:"-"`
// GatewayID: ID of the gateway to upgrade.
GatewayID string `json:"-"`
// Type: gateway type (commercial offer).
Type *string `json:"type,omitempty"`
}
// This API allows you to manage your Public Gateways.
type API struct {
client *scw.Client
}
// NewAPI returns a API object from a Scaleway client.
func NewAPI(client *scw.Client) *API {
return &API{
client: client,
}
}
func (s *API) Zones() []scw.Zone {
return []scw.Zone{scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3}
}
// ListGateways: List Public Gateways in a given Scaleway Organization or Project. By default, results are displayed in ascending order of creation date.
func (s *API) ListGateways(req *ListGatewaysRequest, opts ...scw.RequestOption) (*ListGatewaysResponse, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
defaultPageSize, exist := s.client.GetDefaultPageSize()
if (req.PageSize == nil || *req.PageSize == 0) && exist {
req.PageSize = &defaultPageSize
}
query := url.Values{}
parameter.AddToQuery(query, "order_by", req.OrderBy)
parameter.AddToQuery(query, "page", req.Page)
parameter.AddToQuery(query, "page_size", req.PageSize)
parameter.AddToQuery(query, "organization_id", req.OrganizationID)
parameter.AddToQuery(query, "project_id", req.ProjectID)
parameter.AddToQuery(query, "name", req.Name)
parameter.AddToQuery(query, "tags", req.Tags)
parameter.AddToQuery(query, "types", req.Types)
parameter.AddToQuery(query, "status", req.Status)
parameter.AddToQuery(query, "private_network_ids", req.PrivateNetworkIDs)
parameter.AddToQuery(query, "include_legacy", req.IncludeLegacy)
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways",
Query: query,
}
var resp ListGatewaysResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// GetGateway: Get details of a Public Gateway, specified by its gateway ID. The response object contains full details of the gateway, including its **name**, **type**, **status** and more.
func (s *API) GetGateway(req *GetGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayID) == "" {
return nil, errors.New("field GatewayID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "",
}
var resp Gateway
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// CreateGateway: Create a new Public Gateway in the specified Scaleway Project, defining its **name**, **type** and other configuration details such as whether to enable SSH bastion.
func (s *API) CreateGateway(req *CreateGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if req.ProjectID == "" {
defaultProjectID, _ := s.client.GetDefaultProjectID()
req.ProjectID = defaultProjectID
}
if req.Name == "" {
req.Name = namegenerator.GetRandomName("gw")
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Gateway
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// UpdateGateway: Update the parameters of an existing Public Gateway, for example, its **name**, **tags**, **SSH bastion configuration**, and **DNS servers**.
func (s *API) UpdateGateway(req *UpdateGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayID) == "" {
return nil, errors.New("field GatewayID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "PATCH",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Gateway
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// DeleteGateway: Delete an existing Public Gateway, specified by its gateway ID. This action is irreversible.
func (s *API) DeleteGateway(req *DeleteGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
query := url.Values{}
parameter.AddToQuery(query, "delete_ip", req.DeleteIP)
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayID) == "" {
return nil, errors.New("field GatewayID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "",
Query: query,
}
var resp Gateway
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// UpgradeGateway: Upgrade a given Public Gateway to the newest software version or to a different commercial offer type. This applies the latest bugfixes and features to your Public Gateway. Note that gateway service will be interrupted during the update.
func (s *API) UpgradeGateway(req *UpgradeGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayID) == "" {
return nil, errors.New("field GatewayID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "/upgrade",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Gateway
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// ListGatewayNetworks: List the connections between Public Gateways and Private Networks (a connection = a GatewayNetwork). You can choose to filter by `gateway-id` to list all Private Networks attached to the specified Public Gateway, or by `private_network_id` to list all Public Gateways attached to the specified Private Network. Other query parameters are also available. The result is an array of GatewayNetwork objects, each giving details of the connection between a given Public Gateway and a given Private Network.
func (s *API) ListGatewayNetworks(req *ListGatewayNetworksRequest, opts ...scw.RequestOption) (*ListGatewayNetworksResponse, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
defaultPageSize, exist := s.client.GetDefaultPageSize()
if (req.PageSize == nil || *req.PageSize == 0) && exist {
req.PageSize = &defaultPageSize
}
query := url.Values{}
parameter.AddToQuery(query, "order_by", req.OrderBy)
parameter.AddToQuery(query, "page", req.Page)
parameter.AddToQuery(query, "page_size", req.PageSize)
parameter.AddToQuery(query, "status", req.Status)
parameter.AddToQuery(query, "gateway_ids", req.GatewayIDs)
parameter.AddToQuery(query, "private_network_ids", req.PrivateNetworkIDs)
parameter.AddToQuery(query, "masquerade_enabled", req.MasqueradeEnabled)
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks",
Query: query,
}
var resp ListGatewayNetworksResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// GetGatewayNetwork: Get details of a given connection between a Public Gateway and a Private Network (this connection = a GatewayNetwork), specified by its `gateway_network_id`. The response object contains details of the connection including the IDs of the Public Gateway and Private Network, the dates the connection was created/updated and its configuration settings.
func (s *API) GetGatewayNetwork(req *GetGatewayNetworkRequest, opts ...scw.RequestOption) (*GatewayNetwork, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayNetworkID) == "" {
return nil, errors.New("field GatewayNetworkID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks/" + fmt.Sprint(req.GatewayNetworkID) + "",
}
var resp GatewayNetwork
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// CreateGatewayNetwork: Attach a specific Public Gateway to a specific Private Network (create a GatewayNetwork). You can configure parameters for the connection including whether to enable masquerade (dynamic NAT), and more.
func (s *API) CreateGatewayNetwork(req *CreateGatewayNetworkRequest, opts ...scw.RequestOption) (*GatewayNetwork, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp GatewayNetwork
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// UpdateGatewayNetwork: Update the configuration parameters of a connection between a given Public Gateway and Private Network (the connection = a GatewayNetwork). Updatable parameters include whether to enable traffic masquerade (dynamic NAT).
func (s *API) UpdateGatewayNetwork(req *UpdateGatewayNetworkRequest, opts ...scw.RequestOption) (*GatewayNetwork, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayNetworkID) == "" {
return nil, errors.New("field GatewayNetworkID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "PATCH",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks/" + fmt.Sprint(req.GatewayNetworkID) + "",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp GatewayNetwork
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// DeleteGatewayNetwork: Detach a given Public Gateway from a given Private Network, i.e. delete a GatewayNetwork specified by a gateway_network_id.
func (s *API) DeleteGatewayNetwork(req *DeleteGatewayNetworkRequest, opts ...scw.RequestOption) (*GatewayNetwork, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayNetworkID) == "" {
return nil, errors.New("field GatewayNetworkID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks/" + fmt.Sprint(req.GatewayNetworkID) + "",
}
var resp GatewayNetwork
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// ListPatRules: List PAT rules. You can filter by gateway ID to list all PAT rules for a particular gateway, or filter for PAT rules targeting a specific IP address or using a specific protocol.
func (s *API) ListPatRules(req *ListPatRulesRequest, opts ...scw.RequestOption) (*ListPatRulesResponse, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
defaultPageSize, exist := s.client.GetDefaultPageSize()
if (req.PageSize == nil || *req.PageSize == 0) && exist {
req.PageSize = &defaultPageSize
}
query := url.Values{}
parameter.AddToQuery(query, "order_by", req.OrderBy)
parameter.AddToQuery(query, "page", req.Page)
parameter.AddToQuery(query, "page_size", req.PageSize)
parameter.AddToQuery(query, "gateway_ids", req.GatewayIDs)
parameter.AddToQuery(query, "private_ips", req.PrivateIPs)
parameter.AddToQuery(query, "protocol", req.Protocol)
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/pat-rules",
Query: query,
}
var resp ListPatRulesResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// GetPatRule: Get a PAT rule, specified by its PAT rule ID. The response object gives full details of the PAT rule, including the Public Gateway it belongs to and the configuration settings in terms of public / private ports, private IP and protocol.
func (s *API) GetPatRule(req *GetPatRuleRequest, opts ...scw.RequestOption) (*PatRule, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.PatRuleID) == "" {
return nil, errors.New("field PatRuleID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/pat-rules/" + fmt.Sprint(req.PatRuleID) + "",
}
var resp PatRule
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// CreatePatRule: Create a new PAT rule on a specified Public Gateway, defining the protocol to use, public port to listen on, and private port / IP address to map to.
func (s *API) CreatePatRule(req *CreatePatRuleRequest, opts ...scw.RequestOption) (*PatRule, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/pat-rules",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp PatRule
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// UpdatePatRule: Update a PAT rule, specified by its PAT rule ID. Configuration settings including private/public port, private IP address and protocol can all be updated.
func (s *API) UpdatePatRule(req *UpdatePatRuleRequest, opts ...scw.RequestOption) (*PatRule, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.PatRuleID) == "" {
return nil, errors.New("field PatRuleID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "PATCH",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/pat-rules/" + fmt.Sprint(req.PatRuleID) + "",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp PatRule
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// SetPatRules: Set a definitive list of PAT rules attached to a Public Gateway. Each rule is identified by its public port and protocol. This will sync the current PAT rule list on the gateway with the new list, creating, updating or deleting PAT rules accordingly.
func (s *API) SetPatRules(req *SetPatRulesRequest, opts ...scw.RequestOption) (*SetPatRulesResponse, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "PUT",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/pat-rules",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp SetPatRulesResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// DeletePatRule: Delete a PAT rule, identified by its PAT rule ID. This action is irreversible.
func (s *API) DeletePatRule(req *DeletePatRuleRequest, opts ...scw.RequestOption) error {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.PatRuleID) == "" {
return errors.New("field PatRuleID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/pat-rules/" + fmt.Sprint(req.PatRuleID) + "",
}
err = s.client.Do(scwReq, nil, opts...)
if err != nil {
return err
}
return nil
}
// ListGatewayTypes: List the different Public Gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available gateway type.
func (s *API) ListGatewayTypes(req *ListGatewayTypesRequest, opts ...scw.RequestOption) (*ListGatewayTypesResponse, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateway-types",
}
var resp ListGatewayTypesResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// ListIPs: List Public Gateway flexible IP addresses. A number of filter options are available for limiting results in the response.
func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsResponse, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
defaultPageSize, exist := s.client.GetDefaultPageSize()
if (req.PageSize == nil || *req.PageSize == 0) && exist {
req.PageSize = &defaultPageSize
}
query := url.Values{}
parameter.AddToQuery(query, "order_by", req.OrderBy)
parameter.AddToQuery(query, "page", req.Page)
parameter.AddToQuery(query, "page_size", req.PageSize)
parameter.AddToQuery(query, "organization_id", req.OrganizationID)
parameter.AddToQuery(query, "project_id", req.ProjectID)
parameter.AddToQuery(query, "tags", req.Tags)
parameter.AddToQuery(query, "reverse", req.Reverse)
parameter.AddToQuery(query, "is_free", req.IsFree)
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/ips",
Query: query,
}
var resp ListIPsResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// GetIP: Get details of a Public Gateway flexible IP address, identified by its IP ID. The response object contains information including which (if any) Public Gateway using this IP address, the reverse and various other metadata.
func (s *API) GetIP(req *GetIPRequest, opts ...scw.RequestOption) (*IP, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.IPID) == "" {
return nil, errors.New("field IPID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "",
}
var resp IP
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// CreateIP: Create (reserve) a new flexible IP address that can be used for a Public Gateway in a specified Scaleway Project.
func (s *API) CreateIP(req *CreateIPRequest, opts ...scw.RequestOption) (*IP, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if req.ProjectID == "" {
defaultProjectID, _ := s.client.GetDefaultProjectID()
req.ProjectID = defaultProjectID
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/ips",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp IP
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// UpdateIP: Update details of an existing flexible IP address, including its tags, reverse and the Public Gateway it is assigned to.
func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*IP, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.IPID) == "" {
return nil, errors.New("field IPID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "PATCH",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp IP
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// DeleteIP: Delete a flexible IP address from your account. This action is irreversible.
func (s *API) DeleteIP(req *DeleteIPRequest, opts ...scw.RequestOption) error {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.IPID) == "" {
return errors.New("field IPID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "",
}
err = s.client.Do(scwReq, nil, opts...)
if err != nil {
return err
}
return nil
}
// RefreshSSHKeys: Refresh the SSH keys of a given Public Gateway, specified by its gateway ID. This adds any new SSH keys in the gateway's Scaleway Project to the gateway itself.
func (s *API) RefreshSSHKeys(req *RefreshSSHKeysRequest, opts ...scw.RequestOption) (*Gateway, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayID) == "" {
return nil, errors.New("field GatewayID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "/refresh-ssh-keys",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Gateway
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// AddBastionAllowedIPs: Add an IP range (in CIDR notation) to be allowed to connect to the SSH bastion.
func (s *API) AddBastionAllowedIPs(req *AddBastionAllowedIPsRequest, opts ...scw.RequestOption) (*AddBastionAllowedIPsResponse, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayID) == "" {
return nil, errors.New("field GatewayID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "/bastion-allowed-ips",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp AddBastionAllowedIPsResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// SetBastionAllowedIPs: Set a definitive list of IP ranges (in CIDR notation) allowed to connect to the SSH bastion.
func (s *API) SetBastionAllowedIPs(req *SetBastionAllowedIPsRequest, opts ...scw.RequestOption) (*SetBastionAllowedIPsResponse, error) {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayID) == "" {
return nil, errors.New("field GatewayID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "PUT",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "/bastion-allowed-ips",
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp SetBastionAllowedIPsResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// DeleteBastionAllowedIPs: Delete an IP range (defined in CIDR notation) from SSH bastion, so that it is no longer allowed to connect.
func (s *API) DeleteBastionAllowedIPs(req *DeleteBastionAllowedIPsRequest, opts ...scw.RequestOption) error {
var err error
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if fmt.Sprint(req.Zone) == "" {
return errors.New("field Zone cannot be empty in request")
}
if fmt.Sprint(req.GatewayID) == "" {
return errors.New("field GatewayID cannot be empty in request")
}
if fmt.Sprint(req.IPRange) == "" {
return errors.New("field IPRange cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/vpc-gw/v2/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "/bastion-allowed-ips/" + fmt.Sprint(req.IPRange) + "",
}
err = s.client.Do(scwReq, nil, opts...)
if err != nil {
return err
}
return nil
}
|