File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ from os import environ
4+
35from hcloud import Client
46from hcloud .images import Image
57from hcloud .server_types import ServerType
68
7- # Please paste your API token here between the quotes
8- client = Client (token = "{YOUR_API_TOKEN}" )
9+ assert (
10+ "HCLOUD_TOKEN" in environ
11+ ), "Please export your API token in the HCLOUD_TOKEN environment variable"
12+ token = environ ["HCLOUD_TOKEN" ]
13+
14+ client = Client (token = token )
15+
916response = client .servers .create (
1017 name = "my-server" ,
1118 server_type = ServerType ("cx11" ),
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ from os import environ
4+
35from hcloud import Client
46
5- client = Client (
6- token = "{YOUR_API_TOKEN}"
7- ) # Please paste your API token here between the quotes
7+ assert (
8+ "HCLOUD_TOKEN" in environ
9+ ), "Please export your API token in the HCLOUD_TOKEN environment variable"
10+ token = environ ["HCLOUD_TOKEN" ]
11+
12+ client = Client (token = token )
813servers = client .servers .get_all ()
914print (servers )
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ from os import environ
4+
35from hcloud import Client
46from hcloud .images import Image
57from hcloud .server_types import ServerType
68
9+ assert (
10+ "HCLOUD_TOKEN" in environ
11+ ), "Please export your API token in the HCLOUD_TOKEN environment variable"
12+ token = environ ["HCLOUD_TOKEN" ]
13+
714# Create a client
8- client = Client (token = "project- token" )
15+ client = Client (token = token )
916
1017# Create 2 servers
1118# Create 2 servers
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ from os import environ
4+
35from hcloud import Client
46from hcloud .images import Image
57from hcloud .server_types import ServerType
68from hcloud .servers import Server
79from hcloud .volumes import Volume
810
9- client = Client (token = "project-token" )
11+ assert (
12+ "HCLOUD_TOKEN" in environ
13+ ), "Please export your API token in the HCLOUD_TOKEN environment variable"
14+ token = environ ["HCLOUD_TOKEN" ]
15+
16+ client = Client (token = token )
1017
1118# Create 2 servers
1219response1 = client .servers .create (
You can’t perform that action at this time.
0 commit comments