Skip to content

Commit 80f4310

Browse files
authored
docs: add user-agent to client initialization examples (#625)
1 parent 5e0bd4f commit 80f4310

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ from hcloud import Client
3434
from hcloud.images import Image
3535
from hcloud.server_types import ServerType
3636

37-
client = Client(token="{YOUR_API_TOKEN}") # Please paste your API token here
37+
client = Client(
38+
token="{YOUR_API_TOKEN}", # Please paste your API token here
39+
application_name="my-app",
40+
application_version="v1.0.0",
41+
)
3842

3943
# Create a server named my-server
4044
response = client.servers.create(

examples/create_server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
), "Please export your API token in the HCLOUD_TOKEN environment variable"
1212
token = environ["HCLOUD_TOKEN"]
1313

14-
client = Client(token=token)
14+
client = Client(
15+
token=token,
16+
application_name="examples",
17+
application_version="unknown",
18+
)
1519

1620
response = client.servers.create(
1721
name="my-server",

examples/get_server_metrics.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
), "Please export your API token in the HCLOUD_TOKEN environment variable"
1313
token = environ["HCLOUD_TOKEN"]
1414

15-
client = Client(token=token)
15+
client = Client(
16+
token=token,
17+
application_name="examples",
18+
application_version="unknown",
19+
)
1620

1721
server = client.servers.get_by_name("my-server")
1822
if server is None:

examples/list_servers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
), "Please export your API token in the HCLOUD_TOKEN environment variable"
1010
token = environ["HCLOUD_TOKEN"]
1111

12-
client = Client(token=token)
12+
client = Client(
13+
token=token,
14+
application_name="examples",
15+
application_version="unknown",
16+
)
1317
servers = client.servers.get_all()
1418
print(servers)

examples/usage_oop.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
token = environ["HCLOUD_TOKEN"]
1313

1414
# Create a client
15-
client = Client(token=token)
15+
client = Client(
16+
token=token,
17+
application_name="examples",
18+
application_version="unknown",
19+
)
1620

1721
# Create 2 servers
1822
# Create 2 servers

examples/usage_procedurale.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
), "Please export your API token in the HCLOUD_TOKEN environment variable"
1414
token = environ["HCLOUD_TOKEN"]
1515

16-
client = Client(token=token)
16+
client = Client(
17+
token=token,
18+
application_name="examples",
19+
application_version="unknown",
20+
)
1721

1822
# Create 2 servers
1923
response1 = client.servers.create(

0 commit comments

Comments
 (0)