def ssh_keys_client(self): return SSHKeysClient(client=mock.MagicMock())
def __init__(self, token, api_endpoint="https://api.hetzner.cloud/v1", application_name=None, application_version=None, poll_interval=1): """Create an new Client instance :param token: str Hetzner Cloud API token :param api_endpoint: str Hetzner Cloud API endpoint (default is https://api.hetzner.cloud/v1) :param application_name: str Your application name (default is None) :param application_version: str Your application _version (default is None) :param poll_interval: int Interval for polling information from Hetzner Cloud API in seconds (default is 1) """ self.token = token self._api_endpoint = api_endpoint self._application_name = application_name self._application_version = application_version self.poll_interval = poll_interval self.datacenters = DatacentersClient(self) """DatacentersClient Instance :type: :class:`DatacentersClient <hcloud.datacenters.client.DatacentersClient>` """ self.locations = LocationsClient(self) """LocationsClient Instance :type: :class:`LocationsClient <hcloud.locations.client.LocationsClient>` """ self.servers = ServersClient(self) """ServersClient Instance :type: :class:`ServersClient <hcloud.servers.client.ServersClient>` """ self.server_types = ServerTypesClient(self) """ServerTypesClient Instance :type: :class:`ServerTypesClient <hcloud.server_types.client.ServerTypesClient>` """ self.volumes = VolumesClient(self) """VolumesClient Instance :type: :class:`VolumesClient <hcloud.volumes.client.VolumesClient>` """ self.actions = ActionsClient(self) """ActionsClient Instance :type: :class:`ActionsClient <hcloud.actions.client.ActionsClient>` """ self.images = ImagesClient(self) """ImagesClient Instance :type: :class:`ImagesClient <hcloud.images.client.ImagesClient>` """ self.isos = IsosClient(self) """ImagesClient Instance :type: :class:`IsosClient <hcloud.isos.client.IsosClient>` """ self.ssh_keys = SSHKeysClient(self) """SSHKeysClient Instance :type: :class:`SSHKeysClient <hcloud.ssh_keys.client.SSHKeysClient>` """ self.floating_ips = FloatingIPsClient(self) """FloatingIPsClient Instance :type: :class:`FloatingIPsClient <hcloud.floating_ips.client.FloatingIPsClient>` """ self.networks = NetworksClient(self) """NetworksClient Instance :type: :class:`NetworksClient <hcloud.networks.client.NetworksClient>` """ self.certificates = CertificatesClient(self) """CertificatesClient Instance :type: :class:`CertificatesClient <hcloud.certificates.client.CertificatesClient>` """ self.load_balancers = LoadBalancersClient(self) """LoadBalancersClient Instance :type: :class:`LoadBalancersClient <hcloud.load_balancers.client.LoadBalancersClient>` """ self.load_balancer_types = LoadBalancerTypesClient(self) """LoadBalancerTypesClient Instance
from hcloud.images.domain import Image from hcloud.server_types.domain import ServerType from hcloud.ssh_keys.client import SSHKeysClient from ctrldbops import add_hetzner, get_hetzner import configparser hetzner_config = configparser.ConfigParser() hetzner_config.read('/home/bitclouds/bitclouds/controller/config.ini') hetzner_token = hetzner_config['hetzner']['api_key'] client = Client( token=hetzner_token) # Please paste your API token here between the quotes sshClient = SSHKeysClient(client) def getServers(): hetzner_servers = client.servers.get_all() servers = list() for server in hetzner_servers: serverData = dict() serverData['id'] = server.id serverData['ip'] = server.public_net.ipv4.ip serverData['name'] = server.name servers.append(serverData)