How to use the hcloud.Client function in hcloud

To help you get started, we’ve selected a few hcloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hetznercloud / hcloud-python / tests / unit / test_hcloud.py View on Github external
def test__get_user_agent_with_application_name(self, client):
        client = Client(token="project_token", application_name="my-app")
        user_agent = client._get_user_agent()
        assert user_agent == "my-app hcloud-python/0.0.0"
github hetznercloud / hcloud-python / tests / unit / test_hcloud.py View on Github external
def client(self):
        Client._version = '0.0.0'
        return Client(token="project_token")
github hetznercloud / hcloud-python / tests / unit / test_hcloud.py View on Github external
def test__get_user_agent_with_application_name_and_version(self, client):
        client = Client(token="project_token", application_name="my-app", application_version="1.0.0")
        user_agent = client._get_user_agent()
        assert user_agent == "my-app/1.0.0 hcloud-python/0.0.0"
github hetznercloud / hcloud-python / tests / unit / test_hcloud.py View on Github external
def client(self):
        Client._version = '0.0.0'
        return Client(token="project_token")
github hetznercloud / hcloud-python / examples / usage_procedurale.py View on Github external
from hcloud import Client

from hcloud.images.domain import Image
from hcloud.servers.domain import Server
from hcloud.server_types.domain import ServerType
from hcloud.volumes.domain import Volume

client = Client(token="project-token")

# Create 2 servers
response1 = client.servers.create(
    name="Server1",
    server_type=ServerType(name="cx11"),
    image=Image(id=4711)
)

response2 = client.servers.create(
    "Server2",
    server_type=ServerType(name="cx11"),
    image=Image(id=4711)
)

server1 = response1.server
server2 = response2.server
github hetznercloud / hcloud-python / examples / usage_oop.py View on Github external
from hcloud import Client
from hcloud.images.domain import Image
from hcloud.server_types.domain import ServerType

# Create a client
client = Client(token="project-token")

# Create 2 servers
# Create 2 servers
response1 = client.servers.create(
    "Server1",
    server_type=ServerType(name="cx11"),
    image=Image(id=4711)
)

response2 = client.servers.create(
    "Server2",
    server_type=ServerType(name="cx11"),
    image=Image(id=4711)
)
# Get all servers
server1 = response1.server
github hetznercloud / hcloud-python / examples / create_server.py View on Github external
from hcloud import Client
from hcloud.images.domain import Image
from hcloud.server_types.domain import ServerType

client = Client(token="{YOUR_API_TOKEN}")  # Please paste your API token here between the quotes
response = client.servers.create(name="my-server", server_type=ServerType("cx11"), image=Image(name="ubuntu-20.04"))
server = response.server
print(server)
print("Root Password" + response.root_password)
github hetznercloud / hcloud-python / examples / list_servers.py View on Github external
from hcloud import Client

client = Client(token="{YOUR_API_TOKEN}")  # Please paste your API token here between the quotes
servers = client.servers.get_all()
print(servers)