-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: load token from env in examples scripts (#302)
- Loading branch information
Showing
4 changed files
with
33 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
from __future__ import annotations | ||
|
||
from os import environ | ||
|
||
from hcloud import Client | ||
|
||
client = Client( | ||
token="{YOUR_API_TOKEN}" | ||
) # Please paste your API token here between the quotes | ||
assert ( | ||
"HCLOUD_TOKEN" in environ | ||
), "Please export your API token in the HCLOUD_TOKEN environment variable" | ||
token = environ["HCLOUD_TOKEN"] | ||
|
||
client = Client(token=token) | ||
servers = client.servers.get_all() | ||
print(servers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters