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 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426
|
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
// Package k8s provides methods and message types of the k8s v1 API.
package k8s
import (
"bytes"
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
"strings"
"time"
"github.com/scaleway/scaleway-sdk-go/internal/errors"
"github.com/scaleway/scaleway-sdk-go/internal/marshaler"
"github.com/scaleway/scaleway-sdk-go/internal/parameter"
"github.com/scaleway/scaleway-sdk-go/namegenerator"
"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
)
// API: kapsule API
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,
}
}
type AutoscalerEstimator string
const (
// AutoscalerEstimatorUnknownEstimator is [insert doc].
AutoscalerEstimatorUnknownEstimator = AutoscalerEstimator("unknown_estimator")
// AutoscalerEstimatorBinpacking is [insert doc].
AutoscalerEstimatorBinpacking = AutoscalerEstimator("binpacking")
)
func (enum AutoscalerEstimator) String() string {
if enum == "" {
// return default value if empty
return "unknown_estimator"
}
return string(enum)
}
func (enum AutoscalerEstimator) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *AutoscalerEstimator) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = AutoscalerEstimator(AutoscalerEstimator(tmp).String())
return nil
}
type AutoscalerExpander string
const (
// AutoscalerExpanderUnknownExpander is [insert doc].
AutoscalerExpanderUnknownExpander = AutoscalerExpander("unknown_expander")
// AutoscalerExpanderRandom is [insert doc].
AutoscalerExpanderRandom = AutoscalerExpander("random")
// AutoscalerExpanderMostPods is [insert doc].
AutoscalerExpanderMostPods = AutoscalerExpander("most_pods")
// AutoscalerExpanderLeastWaste is [insert doc].
AutoscalerExpanderLeastWaste = AutoscalerExpander("least_waste")
// AutoscalerExpanderPriority is [insert doc].
AutoscalerExpanderPriority = AutoscalerExpander("priority")
// AutoscalerExpanderPrice is [insert doc].
AutoscalerExpanderPrice = AutoscalerExpander("price")
)
func (enum AutoscalerExpander) String() string {
if enum == "" {
// return default value if empty
return "unknown_expander"
}
return string(enum)
}
func (enum AutoscalerExpander) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *AutoscalerExpander) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = AutoscalerExpander(AutoscalerExpander(tmp).String())
return nil
}
type CNI string
const (
// CNIUnknownCni is [insert doc].
CNIUnknownCni = CNI("unknown_cni")
// CNICilium is [insert doc].
CNICilium = CNI("cilium")
// CNICalico is [insert doc].
CNICalico = CNI("calico")
// CNIWeave is [insert doc].
CNIWeave = CNI("weave")
// CNIFlannel is [insert doc].
CNIFlannel = CNI("flannel")
// CNIKilo is [insert doc].
CNIKilo = CNI("kilo")
)
func (enum CNI) String() string {
if enum == "" {
// return default value if empty
return "unknown_cni"
}
return string(enum)
}
func (enum CNI) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *CNI) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = CNI(CNI(tmp).String())
return nil
}
type ClusterStatus string
const (
// ClusterStatusUnknown is [insert doc].
ClusterStatusUnknown = ClusterStatus("unknown")
// ClusterStatusCreating is [insert doc].
ClusterStatusCreating = ClusterStatus("creating")
// ClusterStatusReady is [insert doc].
ClusterStatusReady = ClusterStatus("ready")
// ClusterStatusDeleting is [insert doc].
ClusterStatusDeleting = ClusterStatus("deleting")
// ClusterStatusDeleted is [insert doc].
ClusterStatusDeleted = ClusterStatus("deleted")
// ClusterStatusUpdating is [insert doc].
ClusterStatusUpdating = ClusterStatus("updating")
// ClusterStatusLocked is [insert doc].
ClusterStatusLocked = ClusterStatus("locked")
// ClusterStatusPoolRequired is [insert doc].
ClusterStatusPoolRequired = ClusterStatus("pool_required")
)
func (enum ClusterStatus) String() string {
if enum == "" {
// return default value if empty
return "unknown"
}
return string(enum)
}
func (enum ClusterStatus) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *ClusterStatus) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = ClusterStatus(ClusterStatus(tmp).String())
return nil
}
type Ingress string
const (
// IngressUnknownIngress is [insert doc].
IngressUnknownIngress = Ingress("unknown_ingress")
// IngressNone is [insert doc].
IngressNone = Ingress("none")
// IngressNginx is [insert doc].
IngressNginx = Ingress("nginx")
// IngressTraefik is [insert doc].
IngressTraefik = Ingress("traefik")
// IngressTraefik2 is [insert doc].
IngressTraefik2 = Ingress("traefik2")
)
func (enum Ingress) String() string {
if enum == "" {
// return default value if empty
return "unknown_ingress"
}
return string(enum)
}
func (enum Ingress) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *Ingress) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = Ingress(Ingress(tmp).String())
return nil
}
type ListClustersRequestOrderBy string
const (
// ListClustersRequestOrderByCreatedAtAsc is [insert doc].
ListClustersRequestOrderByCreatedAtAsc = ListClustersRequestOrderBy("created_at_asc")
// ListClustersRequestOrderByCreatedAtDesc is [insert doc].
ListClustersRequestOrderByCreatedAtDesc = ListClustersRequestOrderBy("created_at_desc")
// ListClustersRequestOrderByUpdatedAtAsc is [insert doc].
ListClustersRequestOrderByUpdatedAtAsc = ListClustersRequestOrderBy("updated_at_asc")
// ListClustersRequestOrderByUpdatedAtDesc is [insert doc].
ListClustersRequestOrderByUpdatedAtDesc = ListClustersRequestOrderBy("updated_at_desc")
// ListClustersRequestOrderByNameAsc is [insert doc].
ListClustersRequestOrderByNameAsc = ListClustersRequestOrderBy("name_asc")
// ListClustersRequestOrderByNameDesc is [insert doc].
ListClustersRequestOrderByNameDesc = ListClustersRequestOrderBy("name_desc")
// ListClustersRequestOrderByStatusAsc is [insert doc].
ListClustersRequestOrderByStatusAsc = ListClustersRequestOrderBy("status_asc")
// ListClustersRequestOrderByStatusDesc is [insert doc].
ListClustersRequestOrderByStatusDesc = ListClustersRequestOrderBy("status_desc")
// ListClustersRequestOrderByVersionAsc is [insert doc].
ListClustersRequestOrderByVersionAsc = ListClustersRequestOrderBy("version_asc")
// ListClustersRequestOrderByVersionDesc is [insert doc].
ListClustersRequestOrderByVersionDesc = ListClustersRequestOrderBy("version_desc")
)
func (enum ListClustersRequestOrderBy) String() string {
if enum == "" {
// return default value if empty
return "created_at_asc"
}
return string(enum)
}
func (enum ListClustersRequestOrderBy) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *ListClustersRequestOrderBy) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = ListClustersRequestOrderBy(ListClustersRequestOrderBy(tmp).String())
return nil
}
type ListNodesRequestOrderBy string
const (
// ListNodesRequestOrderByCreatedAtAsc is [insert doc].
ListNodesRequestOrderByCreatedAtAsc = ListNodesRequestOrderBy("created_at_asc")
// ListNodesRequestOrderByCreatedAtDesc is [insert doc].
ListNodesRequestOrderByCreatedAtDesc = ListNodesRequestOrderBy("created_at_desc")
)
func (enum ListNodesRequestOrderBy) String() string {
if enum == "" {
// return default value if empty
return "created_at_asc"
}
return string(enum)
}
func (enum ListNodesRequestOrderBy) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *ListNodesRequestOrderBy) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = ListNodesRequestOrderBy(ListNodesRequestOrderBy(tmp).String())
return nil
}
type ListPoolsRequestOrderBy string
const (
// ListPoolsRequestOrderByCreatedAtAsc is [insert doc].
ListPoolsRequestOrderByCreatedAtAsc = ListPoolsRequestOrderBy("created_at_asc")
// ListPoolsRequestOrderByCreatedAtDesc is [insert doc].
ListPoolsRequestOrderByCreatedAtDesc = ListPoolsRequestOrderBy("created_at_desc")
// ListPoolsRequestOrderByUpdatedAtAsc is [insert doc].
ListPoolsRequestOrderByUpdatedAtAsc = ListPoolsRequestOrderBy("updated_at_asc")
// ListPoolsRequestOrderByUpdatedAtDesc is [insert doc].
ListPoolsRequestOrderByUpdatedAtDesc = ListPoolsRequestOrderBy("updated_at_desc")
// ListPoolsRequestOrderByNameAsc is [insert doc].
ListPoolsRequestOrderByNameAsc = ListPoolsRequestOrderBy("name_asc")
// ListPoolsRequestOrderByNameDesc is [insert doc].
ListPoolsRequestOrderByNameDesc = ListPoolsRequestOrderBy("name_desc")
// ListPoolsRequestOrderByStatusAsc is [insert doc].
ListPoolsRequestOrderByStatusAsc = ListPoolsRequestOrderBy("status_asc")
// ListPoolsRequestOrderByStatusDesc is [insert doc].
ListPoolsRequestOrderByStatusDesc = ListPoolsRequestOrderBy("status_desc")
// ListPoolsRequestOrderByVersionAsc is [insert doc].
ListPoolsRequestOrderByVersionAsc = ListPoolsRequestOrderBy("version_asc")
// ListPoolsRequestOrderByVersionDesc is [insert doc].
ListPoolsRequestOrderByVersionDesc = ListPoolsRequestOrderBy("version_desc")
)
func (enum ListPoolsRequestOrderBy) String() string {
if enum == "" {
// return default value if empty
return "created_at_asc"
}
return string(enum)
}
func (enum ListPoolsRequestOrderBy) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *ListPoolsRequestOrderBy) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = ListPoolsRequestOrderBy(ListPoolsRequestOrderBy(tmp).String())
return nil
}
type MaintenanceWindowDayOfTheWeek string
const (
// MaintenanceWindowDayOfTheWeekAny is [insert doc].
MaintenanceWindowDayOfTheWeekAny = MaintenanceWindowDayOfTheWeek("any")
// MaintenanceWindowDayOfTheWeekMonday is [insert doc].
MaintenanceWindowDayOfTheWeekMonday = MaintenanceWindowDayOfTheWeek("monday")
// MaintenanceWindowDayOfTheWeekTuesday is [insert doc].
MaintenanceWindowDayOfTheWeekTuesday = MaintenanceWindowDayOfTheWeek("tuesday")
// MaintenanceWindowDayOfTheWeekWednesday is [insert doc].
MaintenanceWindowDayOfTheWeekWednesday = MaintenanceWindowDayOfTheWeek("wednesday")
// MaintenanceWindowDayOfTheWeekThursday is [insert doc].
MaintenanceWindowDayOfTheWeekThursday = MaintenanceWindowDayOfTheWeek("thursday")
// MaintenanceWindowDayOfTheWeekFriday is [insert doc].
MaintenanceWindowDayOfTheWeekFriday = MaintenanceWindowDayOfTheWeek("friday")
// MaintenanceWindowDayOfTheWeekSaturday is [insert doc].
MaintenanceWindowDayOfTheWeekSaturday = MaintenanceWindowDayOfTheWeek("saturday")
// MaintenanceWindowDayOfTheWeekSunday is [insert doc].
MaintenanceWindowDayOfTheWeekSunday = MaintenanceWindowDayOfTheWeek("sunday")
)
func (enum MaintenanceWindowDayOfTheWeek) String() string {
if enum == "" {
// return default value if empty
return "any"
}
return string(enum)
}
func (enum MaintenanceWindowDayOfTheWeek) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *MaintenanceWindowDayOfTheWeek) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = MaintenanceWindowDayOfTheWeek(MaintenanceWindowDayOfTheWeek(tmp).String())
return nil
}
type NodeStatus string
const (
// NodeStatusUnknown is [insert doc].
NodeStatusUnknown = NodeStatus("unknown")
// NodeStatusCreating is [insert doc].
NodeStatusCreating = NodeStatus("creating")
// NodeStatusNotReady is [insert doc].
NodeStatusNotReady = NodeStatus("not_ready")
// NodeStatusReady is [insert doc].
NodeStatusReady = NodeStatus("ready")
// NodeStatusDeleting is [insert doc].
NodeStatusDeleting = NodeStatus("deleting")
// NodeStatusDeleted is [insert doc].
NodeStatusDeleted = NodeStatus("deleted")
// NodeStatusLocked is [insert doc].
NodeStatusLocked = NodeStatus("locked")
// NodeStatusRebooting is [insert doc].
NodeStatusRebooting = NodeStatus("rebooting")
// NodeStatusCreationError is [insert doc].
NodeStatusCreationError = NodeStatus("creation_error")
// NodeStatusUpgrading is [insert doc].
NodeStatusUpgrading = NodeStatus("upgrading")
// NodeStatusStarting is [insert doc].
NodeStatusStarting = NodeStatus("starting")
// NodeStatusRegistering is [insert doc].
NodeStatusRegistering = NodeStatus("registering")
)
func (enum NodeStatus) String() string {
if enum == "" {
// return default value if empty
return "unknown"
}
return string(enum)
}
func (enum NodeStatus) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *NodeStatus) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = NodeStatus(NodeStatus(tmp).String())
return nil
}
type PoolStatus string
const (
// PoolStatusUnknown is [insert doc].
PoolStatusUnknown = PoolStatus("unknown")
// PoolStatusReady is [insert doc].
PoolStatusReady = PoolStatus("ready")
// PoolStatusDeleting is [insert doc].
PoolStatusDeleting = PoolStatus("deleting")
// PoolStatusDeleted is [insert doc].
PoolStatusDeleted = PoolStatus("deleted")
// PoolStatusScaling is [insert doc].
PoolStatusScaling = PoolStatus("scaling")
// PoolStatusWarning is [insert doc].
PoolStatusWarning = PoolStatus("warning")
// PoolStatusLocked is [insert doc].
PoolStatusLocked = PoolStatus("locked")
// PoolStatusUpgrading is [insert doc].
PoolStatusUpgrading = PoolStatus("upgrading")
)
func (enum PoolStatus) String() string {
if enum == "" {
// return default value if empty
return "unknown"
}
return string(enum)
}
func (enum PoolStatus) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *PoolStatus) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = PoolStatus(PoolStatus(tmp).String())
return nil
}
type PoolVolumeType string
const (
// PoolVolumeTypeDefaultVolumeType is [insert doc].
PoolVolumeTypeDefaultVolumeType = PoolVolumeType("default_volume_type")
// PoolVolumeTypeLSSD is [insert doc].
PoolVolumeTypeLSSD = PoolVolumeType("l_ssd")
// PoolVolumeTypeBSSD is [insert doc].
PoolVolumeTypeBSSD = PoolVolumeType("b_ssd")
)
func (enum PoolVolumeType) String() string {
if enum == "" {
// return default value if empty
return "default_volume_type"
}
return string(enum)
}
func (enum PoolVolumeType) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *PoolVolumeType) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = PoolVolumeType(PoolVolumeType(tmp).String())
return nil
}
type Runtime string
const (
// RuntimeUnknownRuntime is [insert doc].
RuntimeUnknownRuntime = Runtime("unknown_runtime")
// RuntimeDocker is [insert doc].
RuntimeDocker = Runtime("docker")
// RuntimeContainerd is [insert doc].
RuntimeContainerd = Runtime("containerd")
// RuntimeCrio is [insert doc].
RuntimeCrio = Runtime("crio")
)
func (enum Runtime) String() string {
if enum == "" {
// return default value if empty
return "unknown_runtime"
}
return string(enum)
}
func (enum Runtime) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}
func (enum *Runtime) UnmarshalJSON(data []byte) error {
tmp := ""
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
*enum = Runtime(Runtime(tmp).String())
return nil
}
// Cluster: cluster
type Cluster struct {
// ID: the ID of the cluster
ID string `json:"id"`
// Type: the type of the cluster
Type string `json:"type"`
// Name: the name of the cluster
Name string `json:"name"`
// Status: the status of the cluster
//
// Default value: unknown
Status ClusterStatus `json:"status"`
// Version: the Kubernetes version of the cluster
Version string `json:"version"`
// Region: the region in which the cluster is
Region scw.Region `json:"region"`
// OrganizationID: the ID of the organization owning the cluster
OrganizationID string `json:"organization_id"`
// ProjectID: the ID of the project owning the cluster
ProjectID string `json:"project_id"`
// Tags: the tags associated with the cluster
Tags []string `json:"tags"`
// Cni: the Container Network Interface (CNI) plugin running in the cluster
//
// Default value: unknown_cni
Cni CNI `json:"cni"`
// Description: the description of the cluster
Description string `json:"description"`
// ClusterURL: the Kubernetes API server URL of the cluster
ClusterURL string `json:"cluster_url"`
// DNSWildcard: the DNS wildcard resovling all the ready nodes of the cluster
DNSWildcard string `json:"dns_wildcard"`
// CreatedAt: the date at which the cluster was created
CreatedAt *time.Time `json:"created_at"`
// UpdatedAt: the date at which the cluster was last updated
UpdatedAt *time.Time `json:"updated_at"`
// AutoscalerConfig: the autoscaler config for the cluster
AutoscalerConfig *ClusterAutoscalerConfig `json:"autoscaler_config"`
// Deprecated: DashboardEnabled: the enablement of the Kubernetes Dashboard in the cluster
DashboardEnabled *bool `json:"dashboard_enabled,omitempty"`
// Deprecated: Ingress: the ingress controller used in the cluster
//
// Default value: unknown_ingress
Ingress *Ingress `json:"ingress,omitempty"`
// AutoUpgrade: the auo upgrade configuration of the cluster
AutoUpgrade *ClusterAutoUpgrade `json:"auto_upgrade"`
// UpgradeAvailable: true if a new Kubernetes version is available
UpgradeAvailable bool `json:"upgrade_available"`
// FeatureGates: list of enabled feature gates
FeatureGates []string `json:"feature_gates"`
// AdmissionPlugins: list of enabled admission plugins
AdmissionPlugins []string `json:"admission_plugins"`
// OpenIDConnectConfig: aLPHA - The OpenID Connect configuration of the cluster
//
// This feature is in ALPHA state, it may be deleted or modified. This configuration is the [OpenID Connect configuration](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#openid-connect-tokens) of the Kubernetes API server.
OpenIDConnectConfig *ClusterOpenIDConnectConfig `json:"open_id_connect_config"`
// ApiserverCertSans: additional Subject Alternative Names for the Kubernetes API server certificate
ApiserverCertSans []string `json:"apiserver_cert_sans"`
}
// ClusterAutoUpgrade: cluster. auto upgrade
type ClusterAutoUpgrade struct {
// Enabled: whether or not auto upgrade is enabled for the cluster
Enabled bool `json:"enabled"`
// MaintenanceWindow: the maintenance window of the cluster auto upgrades
MaintenanceWindow *MaintenanceWindow `json:"maintenance_window"`
}
// ClusterAutoscalerConfig: cluster. autoscaler config
type ClusterAutoscalerConfig struct {
// ScaleDownDisabled: disable the cluster autoscaler
ScaleDownDisabled bool `json:"scale_down_disabled"`
// ScaleDownDelayAfterAdd: how long after scale up that scale down evaluation resumes
ScaleDownDelayAfterAdd string `json:"scale_down_delay_after_add"`
// Estimator: type of resource estimator to be used in scale up
//
// Default value: unknown_estimator
Estimator AutoscalerEstimator `json:"estimator"`
// Expander: type of node group expander to be used in scale up
//
// Default value: unknown_expander
Expander AutoscalerExpander `json:"expander"`
// IgnoreDaemonsetsUtilization: ignore DaemonSet pods when calculating resource utilization for scaling down
IgnoreDaemonsetsUtilization bool `json:"ignore_daemonsets_utilization"`
// BalanceSimilarNodeGroups: detect similar node groups and balance the number of nodes between them
BalanceSimilarNodeGroups bool `json:"balance_similar_node_groups"`
// ExpendablePodsPriorityCutoff: pods with priority below cutoff will be expendable
//
// Pods with priority below cutoff will be expendable. They can be killed without any consideration during scale down and they don't cause scale up. Pods with null priority (PodPriority disabled) are non expendable.
ExpendablePodsPriorityCutoff int32 `json:"expendable_pods_priority_cutoff"`
// ScaleDownUnneededTime: how long a node should be unneeded before it is eligible for scale down
ScaleDownUnneededTime string `json:"scale_down_unneeded_time"`
// ScaleDownUtilizationThreshold: node utilization level, defined as sum of requested resources divided by capacity, below which a node can be considered for scale down
ScaleDownUtilizationThreshold float32 `json:"scale_down_utilization_threshold"`
// MaxGracefulTerminationSec: maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node
MaxGracefulTerminationSec uint32 `json:"max_graceful_termination_sec"`
}
// ClusterOpenIDConnectConfig: cluster. open id connect config
type ClusterOpenIDConnectConfig struct {
// IssuerURL: URL of the provider which allows the API server to discover public signing keys
//
// URL of the provider which allows the API server to discover public signing keys. Only URLs which use the `https://` scheme are accepted. This is typically the provider's discovery URL without a path, for example "https://accounts.google.com" or "https://login.salesforce.com". This URL should point to the level below .well-known/openid-configuration.
//
IssuerURL string `json:"issuer_url"`
// ClientID: a client id that all tokens must be issued for
ClientID string `json:"client_id"`
// UsernameClaim: jWT claim to use as the user name
//
// JWT claim to use as the user name. By default `sub`, which is expected to be a unique identifier of the end user. Admins can choose other claims, such as `email` or `name`, depending on their provider. However, claims other than `email` will be prefixed with the issuer URL to prevent naming clashes with other plugins.
//
UsernameClaim string `json:"username_claim"`
// UsernamePrefix: prefix prepended to username
//
// Prefix prepended to username claims to prevent clashes with existing names (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this flag isn't provided and `username_claim` is a value other than `email` the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `issuer_url`. The value `-` can be used to disable all prefixing.
//
UsernamePrefix string `json:"username_prefix"`
// GroupsClaim: jWT claim to use as the user's group
GroupsClaim []string `json:"groups_claim"`
// GroupsPrefix: prefix prepended to group claims
//
// Prefix prepended to group claims to prevent clashes with existing names (such as `system:` groups). For example, the value `oidc:` will create group names like `oidc:engineering` and `oidc:infra`.
//
GroupsPrefix string `json:"groups_prefix"`
// RequiredClaim: multiple key=value pairs that describes a required claim in the ID Token
//
// Multiple key=value pairs that describes a required claim in the ID Token. If set, the claims are verified to be present in the ID Token with a matching value.
//
RequiredClaim []string `json:"required_claim"`
}
// CreateClusterRequestAutoUpgrade: create cluster request. auto upgrade
type CreateClusterRequestAutoUpgrade struct {
// Enable: whether or not auto upgrade is enabled for the cluster
Enable bool `json:"enable"`
// MaintenanceWindow: the maintenance window of the cluster auto upgrades
MaintenanceWindow *MaintenanceWindow `json:"maintenance_window"`
}
// CreateClusterRequestAutoscalerConfig: create cluster request. autoscaler config
type CreateClusterRequestAutoscalerConfig struct {
// ScaleDownDisabled: disable the cluster autoscaler
ScaleDownDisabled *bool `json:"scale_down_disabled"`
// ScaleDownDelayAfterAdd: how long after scale up that scale down evaluation resumes
ScaleDownDelayAfterAdd *string `json:"scale_down_delay_after_add"`
// Estimator: type of resource estimator to be used in scale up
//
// Default value: unknown_estimator
Estimator AutoscalerEstimator `json:"estimator"`
// Expander: type of node group expander to be used in scale up
//
// Default value: unknown_expander
Expander AutoscalerExpander `json:"expander"`
// IgnoreDaemonsetsUtilization: ignore DaemonSet pods when calculating resource utilization for scaling down
IgnoreDaemonsetsUtilization *bool `json:"ignore_daemonsets_utilization"`
// BalanceSimilarNodeGroups: detect similar node groups and balance the number of nodes between them
BalanceSimilarNodeGroups *bool `json:"balance_similar_node_groups"`
// ExpendablePodsPriorityCutoff: pods with priority below cutoff will be expendable
//
// Pods with priority below cutoff will be expendable. They can be killed without any consideration during scale down and they don't cause scale up. Pods with null priority (PodPriority disabled) are non expendable.
ExpendablePodsPriorityCutoff *int32 `json:"expendable_pods_priority_cutoff"`
// ScaleDownUnneededTime: how long a node should be unneeded before it is eligible for scale down
ScaleDownUnneededTime *string `json:"scale_down_unneeded_time"`
// ScaleDownUtilizationThreshold: node utilization level, defined as sum of requested resources divided by capacity, below which a node can be considered for scale down
ScaleDownUtilizationThreshold *float32 `json:"scale_down_utilization_threshold"`
// MaxGracefulTerminationSec: maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node
MaxGracefulTerminationSec *uint32 `json:"max_graceful_termination_sec"`
}
// CreateClusterRequestOpenIDConnectConfig: create cluster request. open id connect config
type CreateClusterRequestOpenIDConnectConfig struct {
// IssuerURL: URL of the provider which allows the API server to discover public signing keys
//
// URL of the provider which allows the API server to discover public signing keys. Only URLs which use the `https://` scheme are accepted. This is typically the provider's discovery URL without a path, for example "https://accounts.google.com" or "https://login.salesforce.com". This URL should point to the level below .well-known/openid-configuration.
//
IssuerURL string `json:"issuer_url"`
// ClientID: a client id that all tokens must be issued for
ClientID string `json:"client_id"`
// UsernameClaim: jWT claim to use as the user name
//
// JWT claim to use as the user name. By default `sub`, which is expected to be a unique identifier of the end user. Admins can choose other claims, such as `email` or `name`, depending on their provider. However, claims other than `email` will be prefixed with the issuer URL to prevent naming clashes with other plugins.
//
UsernameClaim *string `json:"username_claim"`
// UsernamePrefix: prefix prepended to username
//
// Prefix prepended to username claims to prevent clashes with existing names (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this flag isn't provided and `username_claim` is a value other than `email` the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `issuer_url`. The value `-` can be used to disable all prefixing.
//
UsernamePrefix *string `json:"username_prefix"`
// GroupsClaim: jWT claim to use as the user's group
GroupsClaim *[]string `json:"groups_claim"`
// GroupsPrefix: prefix prepended to group claims
//
// Prefix prepended to group claims to prevent clashes with existing names (such as `system:` groups). For example, the value `oidc:` will create group names like `oidc:engineering` and `oidc:infra`.
//
GroupsPrefix *string `json:"groups_prefix"`
// RequiredClaim: multiple key=value pairs that describes a required claim in the ID Token
//
// Multiple key=value pairs that describes a required claim in the ID Token. If set, the claims are verified to be present in the ID Token with a matching value.
//
RequiredClaim *[]string `json:"required_claim"`
}
// CreateClusterRequestPoolConfig: create cluster request. pool config
type CreateClusterRequestPoolConfig struct {
// Name: the name of the pool
Name string `json:"name"`
// NodeType: the node type is the type of Scaleway Instance wanted for the pool
//
// The node type is the type of Scaleway Instance wanted for the pool. Nodes with insufficient memory are not eligible (DEV1-S, PLAY2-PICO, STARDUST). 'external' is a special node type used to provision instances from other cloud providers.
NodeType string `json:"node_type"`
// PlacementGroupID: the placement group ID in which all the nodes of the pool will be created
PlacementGroupID *string `json:"placement_group_id"`
// Autoscaling: the enablement of the autoscaling feature for the pool
Autoscaling bool `json:"autoscaling"`
// Size: the size (number of nodes) of the pool
Size uint32 `json:"size"`
// MinSize: the minimum size of the pool
//
// The minimum size of the pool. Note that this field will be used only when autoscaling is enabled.
MinSize *uint32 `json:"min_size"`
// MaxSize: the maximum size of the pool
//
// The maximum size of the pool. Note that this field will be used only when autoscaling is enabled.
MaxSize *uint32 `json:"max_size"`
// ContainerRuntime: the container runtime for the nodes of the pool
//
// The customization of the container runtime is available for each pool. Note that `docker` is deprecated since 1.20 and will be removed in 1.24.
//
// Default value: unknown_runtime
ContainerRuntime Runtime `json:"container_runtime"`
// Autohealing: the enablement of the autohealing feature for the pool
Autohealing bool `json:"autohealing"`
// Tags: the tags associated with the pool
Tags []string `json:"tags"`
// KubeletArgs: the Kubelet arguments to be used by this pool. Note that this feature is to be considered as experimental
KubeletArgs map[string]string `json:"kubelet_args"`
// UpgradePolicy: the Pool upgrade policy
UpgradePolicy *CreateClusterRequestPoolConfigUpgradePolicy `json:"upgrade_policy"`
// Zone: the Zone in which the Pool's node will be spawn in
Zone scw.Zone `json:"zone"`
// RootVolumeType: the system volume disk type
//
// The system volume disk type, we provide two different types of volume (`volume_type`):
// - `l_ssd` is a local block storage: your system is stored locally on
// the hypervisor of your node.
// - `b_ssd` is a remote block storage: your system is stored on a
// centralised and resilient cluster.
//
// Default value: default_volume_type
RootVolumeType PoolVolumeType `json:"root_volume_type"`
// RootVolumeSize: the system volume disk size
RootVolumeSize *scw.Size `json:"root_volume_size"`
}
// CreateClusterRequestPoolConfigUpgradePolicy: create cluster request. pool config. upgrade policy
type CreateClusterRequestPoolConfigUpgradePolicy struct {
// MaxUnavailable: the maximum number of nodes that can be not ready at the same time
MaxUnavailable *uint32 `json:"max_unavailable"`
// MaxSurge: the maximum number of nodes to be created during the upgrade
MaxSurge *uint32 `json:"max_surge"`
}
type CreatePoolRequestUpgradePolicy struct {
MaxUnavailable *uint32 `json:"max_unavailable"`
MaxSurge *uint32 `json:"max_surge"`
}
// ListClusterAvailableVersionsResponse: list cluster available versions response
type ListClusterAvailableVersionsResponse struct {
// Versions: the available Kubernetes version for the cluster
Versions []*Version `json:"versions"`
}
// ListClustersResponse: list clusters response
type ListClustersResponse struct {
// TotalCount: the total number of clusters
TotalCount uint32 `json:"total_count"`
// Clusters: the paginated returned clusters
Clusters []*Cluster `json:"clusters"`
}
// ListNodesResponse: list nodes response
type ListNodesResponse struct {
// TotalCount: the total number of nodes
TotalCount uint32 `json:"total_count"`
// Nodes: the paginated returned nodes
Nodes []*Node `json:"nodes"`
}
// ListPoolsResponse: list pools response
type ListPoolsResponse struct {
// TotalCount: the total number of pools that exists for the cluster
TotalCount uint32 `json:"total_count"`
// Pools: the paginated returned pools
Pools []*Pool `json:"pools"`
}
// ListVersionsResponse: list versions response
type ListVersionsResponse struct {
// Versions: the available Kubernetes versions
Versions []*Version `json:"versions"`
}
// MaintenanceWindow: maintenance window
type MaintenanceWindow struct {
// StartHour: the start hour of the 2-hour maintenance window
StartHour uint32 `json:"start_hour"`
// Day: the day of the week for the maintenance window
//
// Default value: any
Day MaintenanceWindowDayOfTheWeek `json:"day"`
}
// Node: node
type Node struct {
// ID: the ID of the node
ID string `json:"id"`
// PoolID: the pool ID of the node
PoolID string `json:"pool_id"`
// ClusterID: the cluster ID of the node
ClusterID string `json:"cluster_id"`
// ProviderID: the underlying instance ID
//
// It is prefixed by instance type and location information (see https://pkg.go.dev/k8s.io/api/core/v1#NodeSpec.ProviderID).
ProviderID string `json:"provider_id"`
// Region: the cluster region of the node
Region scw.Region `json:"region"`
// Name: the name of the node
Name string `json:"name"`
// Deprecated: PublicIPV4: the public IPv4 address of the node
PublicIPV4 *net.IP `json:"public_ip_v4,omitempty"`
// Deprecated: PublicIPV6: the public IPv6 address of the node
PublicIPV6 *net.IP `json:"public_ip_v6,omitempty"`
// Deprecated: Conditions: the conditions of the node
//
// These conditions contains the Node Problem Detector conditions, as well as some in house conditions.
Conditions *map[string]string `json:"conditions,omitempty"`
// Status: the status of the node
//
// Default value: unknown
Status NodeStatus `json:"status"`
// ErrorMessage: details of the error, if any occured when managing the node
ErrorMessage *string `json:"error_message"`
// CreatedAt: the date at which the node was created
CreatedAt *time.Time `json:"created_at"`
// UpdatedAt: the date at which the node was last updated
UpdatedAt *time.Time `json:"updated_at"`
}
// Pool: pool
type Pool struct {
// ID: the ID of the pool
ID string `json:"id"`
// ClusterID: the cluster ID of the pool
ClusterID string `json:"cluster_id"`
// CreatedAt: the date at which the pool was created
CreatedAt *time.Time `json:"created_at"`
// UpdatedAt: the date at which the pool was last updated
UpdatedAt *time.Time `json:"updated_at"`
// Name: the name of the pool
Name string `json:"name"`
// Status: the status of the pool
//
// Default value: unknown
Status PoolStatus `json:"status"`
// Version: the version of the pool
Version string `json:"version"`
// NodeType: the node type is the type of Scaleway Instance wanted for the pool
//
// The node type is the type of Scaleway Instance wanted for the pool. Nodes with insufficient memory are not eligible (DEV1-S, PLAY2-PICO, STARDUST). 'external' is a special node type used to provision instances from other cloud providers.
NodeType string `json:"node_type"`
// Autoscaling: the enablement of the autoscaling feature for the pool
Autoscaling bool `json:"autoscaling"`
// Size: the size (number of nodes) of the pool
Size uint32 `json:"size"`
// MinSize: the minimum size of the pool
//
// The minimum size of the pool. Note that this field will be used only when autoscaling is enabled.
MinSize uint32 `json:"min_size"`
// MaxSize: the maximum size of the pool
//
// The maximum size of the pool. Note that this field will be used only when autoscaling is enabled.
MaxSize uint32 `json:"max_size"`
// ContainerRuntime: the container runtime for the nodes of the pool
//
// The customization of the container runtime is available for each pool. Note that `docker` is deprecated since 1.20 and will be removed in 1.24.
//
// Default value: unknown_runtime
ContainerRuntime Runtime `json:"container_runtime"`
// Autohealing: the enablement of the autohealing feature for the pool
Autohealing bool `json:"autohealing"`
// Tags: the tags associated with the pool
Tags []string `json:"tags"`
// PlacementGroupID: the placement group ID in which all the nodes of the pool will be created
PlacementGroupID *string `json:"placement_group_id"`
// KubeletArgs: the Kubelet arguments to be used by this pool. Note that this feature is to be considered as experimental
KubeletArgs map[string]string `json:"kubelet_args"`
// UpgradePolicy: the Pool upgrade policy
UpgradePolicy *PoolUpgradePolicy `json:"upgrade_policy"`
// Zone: the Zone in which the Pool's node will be spawn in
Zone scw.Zone `json:"zone"`
// RootVolumeType: the system volume disk type
//
// The system volume disk type, we provide two different types of volume (`volume_type`):
// - `l_ssd` is a local block storage: your system is stored locally on
// the hypervisor of your node.
// - `b_ssd` is a remote block storage: your system is stored on a
// centralised and resilient cluster.
//
// Default value: default_volume_type
RootVolumeType PoolVolumeType `json:"root_volume_type"`
// RootVolumeSize: the system volume disk size
RootVolumeSize *scw.Size `json:"root_volume_size"`
// Region: the cluster region of the pool
Region scw.Region `json:"region"`
}
type PoolUpgradePolicy struct {
MaxUnavailable uint32 `json:"max_unavailable"`
MaxSurge uint32 `json:"max_surge"`
}
// UpdateClusterRequestAutoUpgrade: update cluster request. auto upgrade
type UpdateClusterRequestAutoUpgrade struct {
// Enable: whether or not auto upgrade is enabled for the cluster
Enable *bool `json:"enable"`
// MaintenanceWindow: the maintenance window of the cluster auto upgrades
MaintenanceWindow *MaintenanceWindow `json:"maintenance_window"`
}
// UpdateClusterRequestAutoscalerConfig: update cluster request. autoscaler config
type UpdateClusterRequestAutoscalerConfig struct {
// ScaleDownDisabled: disable the cluster autoscaler
ScaleDownDisabled *bool `json:"scale_down_disabled"`
// ScaleDownDelayAfterAdd: how long after scale up that scale down evaluation resumes
ScaleDownDelayAfterAdd *string `json:"scale_down_delay_after_add"`
// Estimator: type of resource estimator to be used in scale up
//
// Default value: unknown_estimator
Estimator AutoscalerEstimator `json:"estimator"`
// Expander: type of node group expander to be used in scale up
//
// Default value: unknown_expander
Expander AutoscalerExpander `json:"expander"`
// IgnoreDaemonsetsUtilization: ignore DaemonSet pods when calculating resource utilization for scaling down
IgnoreDaemonsetsUtilization *bool `json:"ignore_daemonsets_utilization"`
// BalanceSimilarNodeGroups: detect similar node groups and balance the number of nodes between them
BalanceSimilarNodeGroups *bool `json:"balance_similar_node_groups"`
// ExpendablePodsPriorityCutoff: pods with priority below cutoff will be expendable
//
// Pods with priority below cutoff will be expendable. They can be killed without any consideration during scale down and they don't cause scale up. Pods with null priority (PodPriority disabled) are non expendable.
ExpendablePodsPriorityCutoff *int32 `json:"expendable_pods_priority_cutoff"`
// ScaleDownUnneededTime: how long a node should be unneeded before it is eligible for scale down
ScaleDownUnneededTime *string `json:"scale_down_unneeded_time"`
// ScaleDownUtilizationThreshold: node utilization level, defined as sum of requested resources divided by capacity, below which a node can be considered for scale down
ScaleDownUtilizationThreshold *float32 `json:"scale_down_utilization_threshold"`
// MaxGracefulTerminationSec: maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node
MaxGracefulTerminationSec *uint32 `json:"max_graceful_termination_sec"`
}
// UpdateClusterRequestOpenIDConnectConfig: update cluster request. open id connect config
type UpdateClusterRequestOpenIDConnectConfig struct {
// IssuerURL: URL of the provider which allows the API server to discover public signing keys
//
// URL of the provider which allows the API server to discover public signing keys. Only URLs which use the `https://` scheme are accepted. This is typically the provider's discovery URL without a path, for example "https://accounts.google.com" or "https://login.salesforce.com". This URL should point to the level below .well-known/openid-configuration.
//
IssuerURL *string `json:"issuer_url"`
// ClientID: a client id that all tokens must be issued for
ClientID *string `json:"client_id"`
// UsernameClaim: jWT claim to use as the user name
//
// JWT claim to use as the user name. By default `sub`, which is expected to be a unique identifier of the end user. Admins can choose other claims, such as `email` or `name`, depending on their provider. However, claims other than `email` will be prefixed with the issuer URL to prevent naming clashes with other plugins.
//
UsernameClaim *string `json:"username_claim"`
// UsernamePrefix: prefix prepended to username
//
// Prefix prepended to username claims to prevent clashes with existing names (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this flag isn't provided and `username_claim` is a value other than `email` the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `issuer_url`. The value `-` can be used to disable all prefixing.
//
UsernamePrefix *string `json:"username_prefix"`
// GroupsClaim: jWT claim to use as the user's group
GroupsClaim *[]string `json:"groups_claim"`
// GroupsPrefix: prefix prepended to group claims
//
// Prefix prepended to group claims to prevent clashes with existing names (such as `system:` groups). For example, the value `oidc:` will create group names like `oidc:engineering` and `oidc:infra`.
//
GroupsPrefix *string `json:"groups_prefix"`
// RequiredClaim: multiple key=value pairs that describes a required claim in the ID Token
//
// Multiple key=value pairs that describes a required claim in the ID Token. If set, the claims are verified to be present in the ID Token with a matching value.
//
RequiredClaim *[]string `json:"required_claim"`
}
type UpdatePoolRequestUpgradePolicy struct {
MaxUnavailable *uint32 `json:"max_unavailable"`
MaxSurge *uint32 `json:"max_surge"`
}
// Version: version
type Version struct {
// Name: the name of the Kubernetes version
Name string `json:"name"`
// Label: the label of the Kubernetes version
Label string `json:"label"`
// Region: the region in which this version is available
Region scw.Region `json:"region"`
// AvailableCnis: the supported Container Network Interface (CNI) plugins for this version
AvailableCnis []CNI `json:"available_cnis"`
// Deprecated: AvailableIngresses: the supported Ingress Controllers for this version
AvailableIngresses *[]Ingress `json:"available_ingresses,omitempty"`
// AvailableContainerRuntimes: the supported container runtimes for this version
AvailableContainerRuntimes []Runtime `json:"available_container_runtimes"`
// AvailableFeatureGates: the supported feature gates for this version
AvailableFeatureGates []string `json:"available_feature_gates"`
// AvailableAdmissionPlugins: the supported admission plugins for this version
AvailableAdmissionPlugins []string `json:"available_admission_plugins"`
// AvailableKubeletArgs: the supported kubelet arguments for this version
AvailableKubeletArgs map[string]string `json:"available_kubelet_args"`
}
// Service API
// Regions list localities the api is available in
func (s *API) Regions() []scw.Region {
return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw}
}
type ListClustersRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// OrganizationID: the organization ID on which to filter the returned clusters
OrganizationID *string `json:"-"`
// ProjectID: the project ID on which to filter the returned clusters
ProjectID *string `json:"-"`
// OrderBy: the sort order of the returned clusters
//
// Default value: created_at_asc
OrderBy ListClustersRequestOrderBy `json:"-"`
// Page: the page number for the returned clusters
Page *int32 `json:"-"`
// PageSize: the maximum number of clusters per page
PageSize *uint32 `json:"-"`
// Name: the name on which to filter the returned clusters
Name *string `json:"-"`
// Status: the status on which to filter the returned clusters
//
// Default value: unknown
Status ClusterStatus `json:"-"`
// Type: the type on which to filter the returned clusters
Type *string `json:"-"`
}
// ListClusters: list all the clusters
//
// This method allows to list all the existing Kubernetes clusters in an account.
func (s *API) ListClusters(req *ListClustersRequest, opts ...scw.RequestOption) (*ListClustersResponse, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
defaultPageSize, exist := s.client.GetDefaultPageSize()
if (req.PageSize == nil || *req.PageSize == 0) && exist {
req.PageSize = &defaultPageSize
}
query := url.Values{}
parameter.AddToQuery(query, "organization_id", req.OrganizationID)
parameter.AddToQuery(query, "project_id", req.ProjectID)
parameter.AddToQuery(query, "order_by", req.OrderBy)
parameter.AddToQuery(query, "page", req.Page)
parameter.AddToQuery(query, "page_size", req.PageSize)
parameter.AddToQuery(query, "name", req.Name)
parameter.AddToQuery(query, "status", req.Status)
parameter.AddToQuery(query, "type", req.Type)
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters",
Query: query,
Headers: http.Header{},
}
var resp ListClustersResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type CreateClusterRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// Deprecated: OrganizationID: the organization ID where the cluster will be created
// Precisely one of OrganizationID, ProjectID must be set.
OrganizationID *string `json:"organization_id,omitempty"`
// ProjectID: the project ID where the cluster will be created
// Precisely one of OrganizationID, ProjectID must be set.
ProjectID *string `json:"project_id,omitempty"`
// Type: the type of the cluster
Type string `json:"type"`
// Name: the name of the cluster
Name string `json:"name"`
// Description: the description of the cluster
Description string `json:"description"`
// Tags: the tags associated with the cluster
Tags []string `json:"tags"`
// Version: the Kubernetes version of the cluster
Version string `json:"version"`
// Cni: the Container Network Interface (CNI) plugin that will run in the cluster
//
// Default value: unknown_cni
Cni CNI `json:"cni"`
// Deprecated: EnableDashboard: the enablement of the Kubernetes Dashboard in the cluster
EnableDashboard *bool `json:"enable_dashboard,omitempty"`
// Deprecated: Ingress: the Ingress Controller that will run in the cluster
//
// Default value: unknown_ingress
Ingress *Ingress `json:"ingress,omitempty"`
// Pools: the pools to be created along with the cluster
Pools []*CreateClusterRequestPoolConfig `json:"pools"`
// AutoscalerConfig: the autoscaler config for the cluster
//
// This field allows to specify some configuration for the autoscaler, which is an implementation of the [cluster-autoscaler](https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/).
AutoscalerConfig *CreateClusterRequestAutoscalerConfig `json:"autoscaler_config"`
// AutoUpgrade: the auto upgrade configuration of the cluster
//
// This configuration enables to set a specific 2-hour time window in which the cluster can be automatically updated to the latest patch version in the current minor one.
AutoUpgrade *CreateClusterRequestAutoUpgrade `json:"auto_upgrade"`
// FeatureGates: list of feature gates to enable
FeatureGates []string `json:"feature_gates"`
// AdmissionPlugins: list of admission plugins to enable
AdmissionPlugins []string `json:"admission_plugins"`
// OpenIDConnectConfig: aLPHA - The OpenID Connect configuration of the cluster
//
// This feature is in ALPHA state, it may be deleted or modified. This configuration enables to set the [OpenID Connect configuration](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#openid-connect-tokens) of the Kubernetes API server.
OpenIDConnectConfig *CreateClusterRequestOpenIDConnectConfig `json:"open_id_connect_config"`
// ApiserverCertSans: additional Subject Alternative Names for the Kubernetes API server certificate
ApiserverCertSans []string `json:"apiserver_cert_sans"`
}
// CreateCluster: create a new cluster
//
// This method allows to create a new Kubernetes cluster on an account.
func (s *API) CreateCluster(req *CreateClusterRequest, opts ...scw.RequestOption) (*Cluster, error) {
var err error
defaultProjectID, exist := s.client.GetDefaultProjectID()
if exist && req.OrganizationID == nil && req.ProjectID == nil {
req.ProjectID = &defaultProjectID
}
defaultOrganizationID, exist := s.client.GetDefaultOrganizationID()
if exist && req.OrganizationID == nil && req.ProjectID == nil {
req.OrganizationID = &defaultOrganizationID
}
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if req.Name == "" {
req.Name = namegenerator.GetRandomName("k8s")
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters",
Headers: http.Header{},
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Cluster
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type GetClusterRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the ID of the requested cluster
ClusterID string `json:"-"`
}
// GetCluster: get a cluster
//
// This method allows to get details about a specific Kubernetes cluster.
func (s *API) GetCluster(req *GetClusterRequest, opts ...scw.RequestOption) (*Cluster, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "",
Headers: http.Header{},
}
var resp Cluster
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type UpdateClusterRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the ID of the cluster to update
ClusterID string `json:"-"`
// Name: the new name of the cluster
//
// This field allows to update the external name of the cluster. The internal name (used for instance in hostname) won't change.
Name *string `json:"name"`
// Description: the new description of the cluster
Description *string `json:"description"`
// Tags: the new tags associated with the cluster
Tags *[]string `json:"tags"`
// AutoscalerConfig: the new autoscaler config for the cluster
//
// This field allows to update some configuration for the autoscaler, which is an implementation of the [cluster-autoscaler](https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/).
AutoscalerConfig *UpdateClusterRequestAutoscalerConfig `json:"autoscaler_config"`
// Deprecated: EnableDashboard: the new value of the Kubernetes Dashboard enablement
EnableDashboard *bool `json:"enable_dashboard,omitempty"`
// Deprecated: Ingress: the new Ingress Controller for the cluster
//
// Default value: unknown_ingress
Ingress *Ingress `json:"ingress,omitempty"`
// AutoUpgrade: the new auto upgrade configuration of the cluster
//
// The new auto upgrade configuration of the cluster. Note that all fields need to be set.
AutoUpgrade *UpdateClusterRequestAutoUpgrade `json:"auto_upgrade"`
// FeatureGates: list of feature gates to enable
FeatureGates *[]string `json:"feature_gates"`
// AdmissionPlugins: list of admission plugins to enable
AdmissionPlugins *[]string `json:"admission_plugins"`
// OpenIDConnectConfig: aLPHA - The new OpenID Connect configuration of the cluster
//
// This feature is in ALPHA state, it may be deleted or modified. This configuration enables to update the [OpenID Connect configuration](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#openid-connect-tokens) of the Kubernetes API server.
OpenIDConnectConfig *UpdateClusterRequestOpenIDConnectConfig `json:"open_id_connect_config"`
// ApiserverCertSans: additional Subject Alternative Names for the Kubernetes API server certificate
ApiserverCertSans *[]string `json:"apiserver_cert_sans"`
}
// UpdateCluster: update a cluster
//
// This method allows to update a specific Kubernetes cluster. Note that this method is not made to upgrade a Kubernetes cluster.
func (s *API) UpdateCluster(req *UpdateClusterRequest, opts ...scw.RequestOption) (*Cluster, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "PATCH",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "",
Headers: http.Header{},
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Cluster
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type DeleteClusterRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the ID of the cluster to delete
ClusterID string `json:"-"`
// WithAdditionalResources: set true if you want to delete all volumes (including retain volume type) and loadbalancers whose name start with cluster ID
WithAdditionalResources bool `json:"-"`
}
// DeleteCluster: delete a cluster
//
// This method allows to delete a specific cluster and all its associated pools and nodes. Note that this method will not delete any Load Balancers or Block Volumes that are associated with the cluster.
func (s *API) DeleteCluster(req *DeleteClusterRequest, opts ...scw.RequestOption) (*Cluster, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
query := url.Values{}
parameter.AddToQuery(query, "with_additional_resources", req.WithAdditionalResources)
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "",
Query: query,
Headers: http.Header{},
}
var resp Cluster
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type UpgradeClusterRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the ID of the cluster to upgrade
ClusterID string `json:"-"`
// Version: the new Kubernetes version of the cluster
//
// The new Kubernetes version of the cluster. Note that the version shoud either be a higher patch version of the same minor version or the direct minor version after the current one.
Version string `json:"version"`
// UpgradePools: the enablement of the pools upgrade
//
// This field makes the upgrade upgrades the pool once the Kubernetes master in upgrade.
UpgradePools bool `json:"upgrade_pools"`
}
// UpgradeCluster: upgrade a cluster
//
// This method allows to upgrade a specific Kubernetes cluster and/or its associated pools to a specific and supported Kubernetes version.
func (s *API) UpgradeCluster(req *UpgradeClusterRequest, opts ...scw.RequestOption) (*Cluster, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/upgrade",
Headers: http.Header{},
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Cluster
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type ListClusterAvailableVersionsRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the ID of the cluster which the available Kuberentes versions will be listed from
ClusterID string `json:"-"`
}
// ListClusterAvailableVersions: list available versions for a cluster
//
// This method allows to list the versions that a specific Kubernetes cluster is allowed to upgrade to. Note that it will be every patch version greater than the actual one as well a one minor version ahead of the actual one. Upgrades skipping a minor version will not work.
func (s *API) ListClusterAvailableVersions(req *ListClusterAvailableVersionsRequest, opts ...scw.RequestOption) (*ListClusterAvailableVersionsResponse, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/available-versions",
Headers: http.Header{},
}
var resp ListClusterAvailableVersionsResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type GetClusterKubeConfigRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the ID of the cluster to download the kubeconfig from
ClusterID string `json:"-"`
}
// getClusterKubeConfig: download the kubeconfig for a cluster
//
// This method allows to download the Kubernetes cluster config file (AKA kubeconfig) for a specific cluster in order to use it with, for instance, `kubectl`. Tips: add `?dl=1` at the end of the URL to directly get the base64 decoded kubeconfig. If not, the kubeconfig will be base64 encoded.
//
func (s *API) getClusterKubeConfig(req *GetClusterKubeConfigRequest, opts ...scw.RequestOption) (*scw.File, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/kubeconfig",
Headers: http.Header{},
}
var resp scw.File
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type ResetClusterAdminTokenRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the ID of the cluster of which the admin token will be renewed
ClusterID string `json:"-"`
}
// ResetClusterAdminToken: reset the admin token of a cluster
//
// This method allows to reset the admin token for a specific Kubernetes cluster. This will invalidate the old admin token (which will not be usable after) and create a new one. Note that the redownload of the kubeconfig will be necessary to keep interacting with the cluster (if the old admin token was used).
func (s *API) ResetClusterAdminToken(req *ResetClusterAdminTokenRequest, opts ...scw.RequestOption) error {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/reset-admin-token",
Headers: http.Header{},
}
err = scwReq.SetBody(req)
if err != nil {
return err
}
err = s.client.Do(scwReq, nil, opts...)
if err != nil {
return err
}
return nil
}
type ListPoolsRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the ID of the cluster from which the pools will be listed from
ClusterID string `json:"-"`
// OrderBy: the sort order of the returned pools
//
// Default value: created_at_asc
OrderBy ListPoolsRequestOrderBy `json:"-"`
// Page: the page number for the returned pools
Page *int32 `json:"-"`
// PageSize: the maximum number of pools per page
PageSize *uint32 `json:"-"`
// Name: the name on which to filter the returned pools
Name *string `json:"-"`
// Status: the status on which to filter the returned pools
//
// Default value: unknown
Status PoolStatus `json:"-"`
}
// ListPools: list all the pools in a cluster
//
// This method allows to list all the existing pools for a specific Kubernetes cluster.
func (s *API) ListPools(req *ListPoolsRequest, opts ...scw.RequestOption) (*ListPoolsResponse, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
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, "name", req.Name)
parameter.AddToQuery(query, "status", req.Status)
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/pools",
Query: query,
Headers: http.Header{},
}
var resp ListPoolsResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type CreatePoolRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the ID of the cluster in which the pool will be created
ClusterID string `json:"-"`
// Name: the name of the pool
Name string `json:"name"`
// NodeType: the node type is the type of Scaleway Instance wanted for the pool
//
// The node type is the type of Scaleway Instance wanted for the pool. Nodes with insufficient memory are not eligible (DEV1-S, PLAY2-PICO, STARDUST). 'external' is a special node type used to provision instances from other cloud providers.
NodeType string `json:"node_type"`
// PlacementGroupID: the placement group ID in which all the nodes of the pool will be created
PlacementGroupID *string `json:"placement_group_id"`
// Autoscaling: the enablement of the autoscaling feature for the pool
Autoscaling bool `json:"autoscaling"`
// Size: the size (number of nodes) of the pool
Size uint32 `json:"size"`
// MinSize: the minimum size of the pool
//
// The minimum size of the pool. Note that this field will be used only when autoscaling is enabled.
MinSize *uint32 `json:"min_size"`
// MaxSize: the maximum size of the pool
//
// The maximum size of the pool. Note that this field will be used only when autoscaling is enabled.
MaxSize *uint32 `json:"max_size"`
// ContainerRuntime: the container runtime for the nodes of the pool
//
// The customization of the container runtime is available for each pool. Note that `docker` is deprecated since 1.20 and will be removed in 1.24.
//
// Default value: unknown_runtime
ContainerRuntime Runtime `json:"container_runtime"`
// Autohealing: the enablement of the autohealing feature for the pool
Autohealing bool `json:"autohealing"`
// Tags: the tags associated with the pool
Tags []string `json:"tags"`
// KubeletArgs: the Kubelet arguments to be used by this pool. Note that this feature is to be considered as experimental
KubeletArgs map[string]string `json:"kubelet_args"`
// UpgradePolicy: the Pool upgrade policy
UpgradePolicy *CreatePoolRequestUpgradePolicy `json:"upgrade_policy"`
// Zone: the Zone in which the Pool's node will be spawn in
Zone scw.Zone `json:"zone"`
// RootVolumeType: the system volume disk type
//
// The system volume disk type, we provide two different types of volume (`volume_type`):
// - `l_ssd` is a local block storage: your system is stored locally on
// the hypervisor of your node.
// - `b_ssd` is a remote block storage: your system is stored on a
// centralised and resilient cluster.
//
// Default value: default_volume_type
RootVolumeType PoolVolumeType `json:"root_volume_type"`
// RootVolumeSize: the system volume disk size
RootVolumeSize *scw.Size `json:"root_volume_size"`
}
// CreatePool: create a new pool in a cluster
//
// This method allows to create a new pool in a specific Kubernetes cluster.
func (s *API) CreatePool(req *CreatePoolRequest, opts ...scw.RequestOption) (*Pool, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}
if req.Name == "" {
req.Name = namegenerator.GetRandomName("pool")
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/pools",
Headers: http.Header{},
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Pool
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type GetPoolRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// PoolID: the ID of the requested pool
PoolID string `json:"-"`
}
// GetPool: get a pool in a cluster
//
// This method allows to get details about a specific pool.
func (s *API) GetPool(req *GetPoolRequest, opts ...scw.RequestOption) (*Pool, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.PoolID) == "" {
return nil, errors.New("field PoolID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/pools/" + fmt.Sprint(req.PoolID) + "",
Headers: http.Header{},
}
var resp Pool
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type UpgradePoolRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// PoolID: the ID of the pool to upgrade
PoolID string `json:"-"`
// Version: the new Kubernetes version for the pool
Version string `json:"version"`
}
// UpgradePool: upgrade a pool in a cluster
//
// This method allows to upgrade the Kubernetes version of a specific pool. Note that this will work when the targeted version is the same than the version of the cluster.
func (s *API) UpgradePool(req *UpgradePoolRequest, opts ...scw.RequestOption) (*Pool, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.PoolID) == "" {
return nil, errors.New("field PoolID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/pools/" + fmt.Sprint(req.PoolID) + "/upgrade",
Headers: http.Header{},
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Pool
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type UpdatePoolRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// PoolID: the ID of the pool to update
PoolID string `json:"-"`
// Autoscaling: the new value for the enablement of autoscaling for the pool
Autoscaling *bool `json:"autoscaling"`
// Size: the new size for the pool
Size *uint32 `json:"size"`
// MinSize: the new minimun size for the pool
MinSize *uint32 `json:"min_size"`
// MaxSize: the new maximum size for the pool
MaxSize *uint32 `json:"max_size"`
// Autohealing: the new value for the enablement of autohealing for the pool
Autohealing *bool `json:"autohealing"`
// Tags: the new tags associated with the pool
Tags *[]string `json:"tags"`
// KubeletArgs: the new Kubelet arguments to be used by this pool. Note that this feature is to be considered as experimental
KubeletArgs *map[string]string `json:"kubelet_args"`
// UpgradePolicy: the Pool upgrade policy
UpgradePolicy *UpdatePoolRequestUpgradePolicy `json:"upgrade_policy"`
}
// UpdatePool: update a pool in a cluster
//
// This method allows to update some attributes of a specific pool such as the size, the autoscaling enablement, the tags, ...
func (s *API) UpdatePool(req *UpdatePoolRequest, opts ...scw.RequestOption) (*Pool, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.PoolID) == "" {
return nil, errors.New("field PoolID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "PATCH",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/pools/" + fmt.Sprint(req.PoolID) + "",
Headers: http.Header{},
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Pool
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type DeletePoolRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// PoolID: the ID of the pool to delete
PoolID string `json:"-"`
}
// DeletePool: delete a pool in a cluster
//
// This method allows to delete a specific pool from a cluster, deleting all the nodes associated with it.
func (s *API) DeletePool(req *DeletePoolRequest, opts ...scw.RequestOption) (*Pool, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.PoolID) == "" {
return nil, errors.New("field PoolID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/pools/" + fmt.Sprint(req.PoolID) + "",
Headers: http.Header{},
}
var resp Pool
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type ListNodesRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// ClusterID: the cluster ID from which the nodes will be listed from
ClusterID string `json:"-"`
// PoolID: the pool ID on which to filter the returned nodes
PoolID *string `json:"-"`
// OrderBy: the sort order of the returned nodes
//
// Default value: created_at_asc
OrderBy ListNodesRequestOrderBy `json:"-"`
// Page: the page number for the returned nodes
Page *int32 `json:"-"`
// PageSize: the maximum number of nodes per page
PageSize *uint32 `json:"-"`
// Name: the name on which to filter the returned nodes
Name *string `json:"-"`
// Status: the status on which to filter the returned nodes
//
// Default value: unknown
Status NodeStatus `json:"-"`
}
// ListNodes: list all the nodes in a cluster
//
// This method allows to list all the existing nodes for a specific Kubernetes cluster.
func (s *API) ListNodes(req *ListNodesRequest, opts ...scw.RequestOption) (*ListNodesResponse, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
defaultPageSize, exist := s.client.GetDefaultPageSize()
if (req.PageSize == nil || *req.PageSize == 0) && exist {
req.PageSize = &defaultPageSize
}
query := url.Values{}
parameter.AddToQuery(query, "pool_id", req.PoolID)
parameter.AddToQuery(query, "order_by", req.OrderBy)
parameter.AddToQuery(query, "page", req.Page)
parameter.AddToQuery(query, "page_size", req.PageSize)
parameter.AddToQuery(query, "name", req.Name)
parameter.AddToQuery(query, "status", req.Status)
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/nodes",
Query: query,
Headers: http.Header{},
}
var resp ListNodesResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type GetNodeRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// NodeID: the ID of the requested node
NodeID string `json:"-"`
}
// GetNode: get a node in a cluster
//
// This method allows to get details about a specific Kubernetes node.
func (s *API) GetNode(req *GetNodeRequest, opts ...scw.RequestOption) (*Node, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.NodeID) == "" {
return nil, errors.New("field NodeID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/nodes/" + fmt.Sprint(req.NodeID) + "",
Headers: http.Header{},
}
var resp Node
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type ReplaceNodeRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// NodeID: the ID of the node to replace
NodeID string `json:"-"`
}
// Deprecated: ReplaceNode: replace a node in a cluster
//
// This method allows to replace a specific node. The node will be set cordoned, meaning that scheduling will be disabled. Then the existing pods on the node will be drained and reschedule onto another schedulable node. Then the node will be deleted, and a new one will be created after the deletion. Note that when there is not enough space to reschedule all the pods (in a one node cluster for instance), you may experience some disruption of your applications.
func (s *API) ReplaceNode(req *ReplaceNodeRequest, opts ...scw.RequestOption) (*Node, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.NodeID) == "" {
return nil, errors.New("field NodeID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/nodes/" + fmt.Sprint(req.NodeID) + "/replace",
Headers: http.Header{},
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Node
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type RebootNodeRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// NodeID: the ID of the node to reboot
NodeID string `json:"-"`
}
// RebootNode: reboot a node in a cluster
//
// This method allows to reboot a specific node. This node will frist be cordoned, meaning that scheduling will be disabled. Then the existing pods on the node will be drained and reschedule onto another schedulable node. Note that when there is not enough space to reschedule all the pods (in a one node cluster for instance), you may experience some disruption of your applications.
func (s *API) RebootNode(req *RebootNodeRequest, opts ...scw.RequestOption) (*Node, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.NodeID) == "" {
return nil, errors.New("field NodeID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/nodes/" + fmt.Sprint(req.NodeID) + "/reboot",
Headers: http.Header{},
}
err = scwReq.SetBody(req)
if err != nil {
return nil, err
}
var resp Node
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type DeleteNodeRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// NodeID: the ID of the node to replace
NodeID string `json:"-"`
// SkipDrain: skip draining node from its workload
SkipDrain bool `json:"-"`
// Replace: add a new node after the deletion of this node
Replace bool `json:"-"`
}
// DeleteNode: delete a node in a cluster
//
// This method allows to delete a specific node. Note that when there is not enough space to reschedule all the pods (in a one node cluster for instance), you may experience some disruption of your applications.
func (s *API) DeleteNode(req *DeleteNodeRequest, opts ...scw.RequestOption) (*Node, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
query := url.Values{}
parameter.AddToQuery(query, "skip_drain", req.SkipDrain)
parameter.AddToQuery(query, "replace", req.Replace)
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.NodeID) == "" {
return nil, errors.New("field NodeID cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/nodes/" + fmt.Sprint(req.NodeID) + "",
Query: query,
Headers: http.Header{},
}
var resp Node
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type ListVersionsRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
}
// ListVersions: list all available versions
//
// This method allows to list all available versions for the creation of a new Kubernetes cluster.
func (s *API) ListVersions(req *ListVersionsRequest, opts ...scw.RequestOption) (*ListVersionsResponse, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/versions",
Headers: http.Header{},
}
var resp ListVersionsResponse
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
type GetVersionRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`
// VersionName: the requested version name
VersionName string `json:"-"`
}
// GetVersion: get details about a specific version
//
// This method allows to get a specific Kubernetes version and the details about the version.
func (s *API) GetVersion(req *GetVersionRequest, opts ...scw.RequestOption) (*Version, error) {
var err error
if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}
if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}
if fmt.Sprint(req.VersionName) == "" {
return nil, errors.New("field VersionName cannot be empty in request")
}
scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/versions/" + fmt.Sprint(req.VersionName) + "",
Headers: http.Header{},
}
var resp Version
err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}
// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListClustersResponse) UnsafeGetTotalCount() uint32 {
return r.TotalCount
}
// UnsafeAppend should not be used
// Internal usage only
func (r *ListClustersResponse) UnsafeAppend(res interface{}) (uint32, error) {
results, ok := res.(*ListClustersResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}
r.Clusters = append(r.Clusters, results.Clusters...)
r.TotalCount += uint32(len(results.Clusters))
return uint32(len(results.Clusters)), nil
}
// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListPoolsResponse) UnsafeGetTotalCount() uint32 {
return r.TotalCount
}
// UnsafeAppend should not be used
// Internal usage only
func (r *ListPoolsResponse) UnsafeAppend(res interface{}) (uint32, error) {
results, ok := res.(*ListPoolsResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}
r.Pools = append(r.Pools, results.Pools...)
r.TotalCount += uint32(len(results.Pools))
return uint32(len(results.Pools)), nil
}
// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListNodesResponse) UnsafeGetTotalCount() uint32 {
return r.TotalCount
}
// UnsafeAppend should not be used
// Internal usage only
func (r *ListNodesResponse) UnsafeAppend(res interface{}) (uint32, error) {
results, ok := res.(*ListNodesResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}
r.Nodes = append(r.Nodes, results.Nodes...)
r.TotalCount += uint32(len(results.Nodes))
return uint32(len(results.Nodes)), nil
}
|