How to use the hcloud.core.client.GetEntityByNameMixin 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 / hcloud / locations / client.py View on Github external
# -*- coding: utf-8 -*-
from hcloud.core.client import ClientEntityBase, BoundModelBase, GetEntityByNameMixin

from hcloud.locations.domain import Location


class BoundLocation(BoundModelBase):
    model = Location


class LocationsClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = 'locations'

    def get_by_id(self, id):
        # type: (int) -> locations.client.BoundLocation
        """Get a specific location by its ID.

        :param id: int
        :return: :class:`BoundLocation `
        """
        response = self._client.request(url="/locations/{location_id}".format(location_id=id), method="GET")
        return BoundLocation(self, response['location'])

    def get_list(self, name=None, page=None, per_page=None):
        # type: (Optional[str], Optional[int], Optional[int]) -> PageResult[List[BoundLocation], Meta]
        """Get a list of locations
github hetznercloud / hcloud-python / hcloud / images / client.py View on Github external
:return: bool
        """
        return self._client.delete(self)

    def change_protection(self, delete=None):
        # type: (Optional[bool]) -> BoundAction
        """Changes the protection configuration of the image. Can only be used on snapshots.

        :param delete: bool
               If true, prevents the snapshot from being deleted
        :return: :class:`BoundAction `
        """
        return self._client.change_protection(self, delete)


class ImagesClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = 'images'

    def get_actions_list(self,
                         image,         # type: Image
                         sort=None,     # type: Optional[List[str]]
                         page=None,     # type: Optional[int]
                         per_page=None,  # type: Optional[int]
                         status=None,  # type: Optional[List[str]]
                         ):
        # type: (...) -> PageResults[List[BoundAction], Meta]
        """Returns a list of action objects for an image.

        :param image: :class:`BoundImage ` or :class:`Image `
        :param status: List[str] (optional)
               Response will have only actions with specified statuses. Choices: `running` `success` `error`
        :param sort: List[str] (optional)
github hetznercloud / hcloud-python / hcloud / servers / client.py View on Github external
"""
        return self._client.detach_from_network(self, network)

    def change_alias_ips(self, network, alias_ips):
        # type: (Union[Network,BoundNetwork], List[str]) -> BoundAction
        """Changes the alias IPs of an already attached network.

        :param network: :class:`BoundNetwork ` or :class:`Network `
        :param alias_ips: List[str]
                New alias IPs to set for this server.
        :return: :class:`BoundAction `
        """
        return self._client.change_alias_ips(self, network, alias_ips)


class ServersClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = 'servers'

    def get_by_id(self, id):
        # type: (int) -> BoundServer
        """Get a specific server

        :param id: int
        :return: :class:`BoundServer `
        """
        response = self._client.request(url="/servers/{server_id}".format(server_id=id), method="GET")
        return BoundServer(self, response['server'])

    def get_list(self,
                 name=None,  # type: Optional[str]
                 label_selector=None,  # type: Optional[str]
                 page=None,  # type: Optional[int]
github hetznercloud / hcloud-python / hcloud / load_balancers / client.py View on Github external
"""Enables the public interface of a Load Balancer.

        :return: :class:`BoundAction `
        """
        return self._client.enable_public_interface(self)

    def disable_public_interface(self):
        # type: ( Union[Network,BoundNetwork]) -> BoundAction
        """Disables the public interface of a Load Balancer.

        :return: :class:`BoundAction `
        """
        return self._client.disable_public_interface(self)


class LoadBalancersClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = "load_balancers"

    def get_by_id(self, id):
        # type: (int) -> BoundLoadBalancer
        """Get a specific Load Balancer

        :param id: int
        :return: :class:`BoundLoadBalancer 
        """
        response = self._client.request(
            url="/load_balancers/{load_balancer_id}".format(load_balancer_id=id), method="GET"
        )
        return BoundLoadBalancer(self, response["load_balancer"])

    def get_list(
            self,
github hetznercloud / hcloud-python / hcloud / floating_ips / client.py View on Github external
return self._client.unassign(self)

    def change_dns_ptr(self, ip, dns_ptr):
        # type: (str, str) -> BoundAction
        """Changes the hostname that will appear when getting the hostname belonging to this Floating IP.

        :param ip: str
               The IP address for which to set the reverse DNS entry
        :param dns_ptr: str
               Hostname to set as a reverse DNS PTR entry, will reset to original default value if `None`
        :return: :class:`BoundAction `
        """
        return self._client.change_dns_ptr(self, ip, dns_ptr)


class FloatingIPsClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = 'floating_ips'

    def get_actions_list(self,
                         floating_ip,  # type: FloatingIP
                         status=None,  # type: Optional[List[str]]
                         sort=None,  # type: Optional[List[str]]
                         page=None,  # type: Optional[int]
                         per_page=None  # type: Optional[int]
                         ):
        # type: (...) -> PageResults[List[BoundAction], Meta]
        """Returns all action objects for a Floating IP.

        :param floating_ip: :class:`BoundFloatingIP ` or  :class:`FloatingIP `
        :param status: List[str] (optional)
               Response will have only actions with specified statuses. Choices: `running` `success` `error`
        :param sort: List[str] (optional)
github hetznercloud / hcloud-python / hcloud / volumes / client.py View on Github external
:return: :class:`BoundAction `
        """
        return self._client.resize(self, size)

    def change_protection(self, delete=None):
        # type: (Optional[bool]) -> BoundAction
        """Changes the protection configuration of a volume.

        :param delete: boolean
               If True, prevents the volume from being deleted
        :return: :class:`BoundAction `
        """
        return self._client.change_protection(self, delete)


class VolumesClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = 'volumes'

    def get_by_id(self, id):
        # type: (int) -> volumes.client.BoundVolume
        """Get a specific volume by its id

        :param id: int
        :return: :class:`BoundVolume `
        """
        response = self._client.request(url="/volumes/{volume_id}".format(volume_id=id), method="GET")
        return BoundVolume(self, response['volume'])

    def get_list(self, name=None, label_selector=None, page=None, per_page=None, status=None):
        # type: (Optional[str], Optional[str], Optional[int], Optional[int], Optional[List[str]]) -> PageResults[List[BoundVolume], Meta]
        """Get a list of volumes from this account
github hetznercloud / hcloud-python / hcloud / certificates / client.py View on Github external
New name to set
        :param labels: Dict[str, str] (optional)
               User-defined labels (key-value pairs)
        :return: :class:`BoundCertificate 
        """
        return self._client.update(self, name, labels)

    def delete(self):
        # type: () -> bool
        """Deletes a certificate.
           :return: boolean
        """
        return self._client.delete(self)


class CertificatesClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = 'certificates'

    def get_by_id(self, id):
        # type: (int) -> BoundCertificate
        """Get a specific certificate by its ID.

        :param id: int
        :return: :class:`BoundCertificate `
        """
        response = self._client.request(url="/certificates/{certificate_id}".format(certificate_id=id), method="GET")
        return BoundCertificate(self, response['certificate'])

    def get_list(self,
                 name=None,  # type: Optional[str]
                 label_selector=None,  # type: Optional[str]
                 page=None,  # type: Optional[int]
github hetznercloud / hcloud-python / hcloud / ssh_keys / client.py View on Github external
New Description to set
        :param labels: Dict[str, str] (optional)
               User-defined labels (key-value pairs)
        :return: :class:`BoundSSHKey 
        """
        return self._client.update(self, name, labels)

    def delete(self):
        # type: () -> bool
        """Deletes an SSH key. It cannot be used anymore.
           :return: boolean
        """
        return self._client.delete(self)


class SSHKeysClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = 'ssh_keys'

    def get_by_id(self, id):
        # type: (int) -> BoundSSHKey
        """Get a specific SSH Key by its ID

        :param id: int
        :return: :class:`BoundSSHKey `
        """
        response = self._client.request(url="/ssh_keys/{ssh_key_id}".format(ssh_key_id=id), method="GET")
        return BoundSSHKey(self, response['ssh_key'])

    def get_list(self,
                 name=None,  # type: Optional[str]
                 fingerprint=None,  # type: Optional[str]
                 label_selector=None,  # type: Optional[str]
github hetznercloud / hcloud-python / hcloud / server_types / client.py View on Github external
from hcloud.core.client import ClientEntityBase, BoundModelBase, GetEntityByNameMixin
from hcloud.server_types.domain import ServerType


class BoundServerType(BoundModelBase):
    model = ServerType


class ServerTypesClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = 'server_types'

    def get_by_id(self, id):
        # type: (int) -> server_types.client.BoundServerType
        """Returns a specific Server Type.

        :param id: int
        :return: :class:`BoundServerType `
        """
        response = self._client.request(url="/server_types/{server_type_id}".format(server_type_id=id), method="GET")
        return BoundServerType(self, response['server_type'])

    def get_list(self, name=None, page=None, per_page=None):
        # type: (Optional[str], Optional[int], Optional[int]) -> PageResults[List[BoundServerType], Meta]
        """Get a list of Server types
github hetznercloud / hcloud-python / hcloud / isos / client.py View on Github external
# -*- coding: utf-8 -*-
from hcloud.core.client import BoundModelBase, ClientEntityBase, GetEntityByNameMixin

from hcloud.isos.domain import Iso


class BoundIso(BoundModelBase):
    model = Iso


class IsosClient(ClientEntityBase, GetEntityByNameMixin):
    results_list_attribute_name = 'isos'

    def get_by_id(self, id):
        # type: (int) -> BoundIso
        """Get a specific ISO by its id

        :param id: int
        :return: :class:`BoundIso `
        """
        response = self._client.request(url="/isos/{iso_id}".format(iso_id=id), method="GET")
        return BoundIso(self, response['iso'])

    def get_list(self,
                 name=None,      # type: Optional[str]
                 page=None,      # type: Optional[int]
                 per_page=None,  # type: Optional[int]