def __init__(self, client, data): location = data.get("location") if location is not None: data["location"] = BoundLocation(client._client.locations, location) server_types = data.get("server_types") if server_types is not None: available = [ BoundServerType(client._client.server_types, {"id": server_type}, complete=False) for server_type in server_types["available"] ] supported = [ BoundServerType(client._client.server_types, {"id": server_type}, complete=False) for server_type in server_types["supported"] ] available_for_migration = [ BoundServerType(client._client.server_types, {"id": server_type}, complete=False) for server_type in server_types["available_for_migration"] ] data["server_types"] = DatacenterServerTypes( available=available, supported=supported, available_for_migration=available_for_migration, ) super(BoundDatacenter, self).__init__(client, data)
def __init__(self, client, data, complete=True): location = data.get("location") if location is not None: data['location'] = BoundLocation(client._client.locations, location) from hcloud.servers.client import BoundServer server = data.get("server") if server is not None: data['server'] = BoundServer(client._client.servers, {"id": server}, complete=False) super(BoundVolume, self).__init__(client, data, complete)
def __init__(self, client, data, complete=True): from hcloud.servers.client import BoundServer server = data.get("server") if server is not None: data['server'] = BoundServer(client._client.servers, {"id": server}, complete=False) home_location = data.get("home_location") if home_location is not None: data['home_location'] = BoundLocation(client._client.locations, home_location) super(BoundFloatingIP, self).__init__(client, data, complete)
def __init__(self, client, data, complete=True): algorithm = data.get("algorithm") if algorithm: data['algorithm'] = LoadBalancerAlgorithm(type=algorithm['type']) public_net = data.get("public_net") if public_net: ipv4_address = IPv4Address(**public_net['ipv4']) ipv6_network = IPv6Network(**public_net['ipv6']) data['public_net'] = PublicNetwork(ipv4=ipv4_address, ipv6=ipv6_network, enabled=public_net['enabled']) private_nets = data.get("private_net") if private_nets: private_nets = [ PrivateNet(network=BoundNetwork(client._client.networks, {"id": private_net['network']}, complete=False), ip=private_net['ip']) for private_net in private_nets ] data['private_net'] = private_nets targets = data.get("targets") if targets: tmp_targets = [] for target in targets: tmp_target = LoadBalancerTarget(type=target["type"]) if target["type"] == "server": tmp_target.server = BoundServer(client._client.servers, data=target['server'], complete=False) tmp_target.use_private_ip = target["use_private_ip"] elif target["type"] == "label_selector": tmp_target.label_selector = LoadBalancerTargetLabelSelector( selector=target['label_selector']['selector']) tmp_target.use_private_ip = target["use_private_ip"] elif target["type"] == "ip": tmp_target.ip = LoadBalancerTargetIP(ip=target['ip']['ip']) tmp_targets.append(tmp_target) data['targets'] = tmp_targets services = data.get("services") if services: tmp_services = [] for service in services: tmp_service = LoadBalancerService( protocol=service["protocol"], listen_port=service["listen_port"], destination_port=service["destination_port"], proxyprotocol=service["proxyprotocol"]) if service["protocol"] != "tcp": tmp_service.http = LoadBalancerServiceHttp( sticky_sessions=service['http']['sticky_sessions'], redirect_http=service['http']['redirect_http'], cookie_name=service['http']['cookie_name'], cookie_lifetime=service['http']['cookie_lifetime']) tmp_service.http.certificates = [ BoundCertificate(client._client.certificates, {"id": certificate}, complete=False) for certificate in service['http']['certificates'] ] tmp_service.health_check = LoadBalancerHealthCheck( protocol=service['health_check']['protocol'], port=service['health_check']['port'], interval=service['health_check']['interval'], retries=service['health_check']['retries'], timeout=service['health_check']['timeout']) if tmp_service.health_check.protocol != "tcp": tmp_service.health_check.http = LoadBalancerHealtCheckHttp( domain=service['health_check']['http']['domain'], path=service['health_check']['http']['path'], response=service['health_check']['http']['response'], tls=service['health_check']['http']['tls'], status_codes=service['health_check']['http'] ['status_codes']) tmp_services.append(tmp_service) data['services'] = tmp_services load_balancer_type = data.get("load_balancer_type") if load_balancer_type is not None: data['load_balancer_type'] = BoundLoadBalancerType( client._client.load_balancer_types, load_balancer_type) location = data.get("location") if location is not None: data['location'] = BoundLocation(client._client.locations, location) super(BoundLoadBalancer, self).__init__(client, data, complete)