How to use the hcloud.actions.client.BoundAction 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 / servers / test_client.py View on Github external
"start_after_create": False
            }
        )

        bound_server = response.server
        bound_action = response.action
        next_actions = response.next_actions
        root_password = response.root_password

        assert root_password == "YItygq1v3GYjjMomLaKc"

        assert bound_server._client is servers_client
        assert bound_server.id == 1
        assert bound_server.name == "my-server"

        assert isinstance(bound_action, BoundAction)
        assert bound_action._client == servers_client._client.actions
        assert bound_action.id == 1
        assert bound_action.command == "create_server"

        assert next_actions[0].id == 13
github hetznercloud / hcloud-python / hcloud / servers / client.py View on Github external
def disable_backup(self, server):
        # type: (servers.domain.Server) -> actions.domainAction
        """Disables the automatic backup option and deletes all existing Backups for a Server.

        :param server: :class:`BoundServer ` or :class:`Server `
        :return: :class:`BoundAction `
        """
        response = self._client.request(url="/servers/{server_id}/actions/disable_backup".format(server_id=server.id),
                                        method="POST")
        return BoundAction(self._client.actions, response['action'])
github hetznercloud / hcloud-python / hcloud / servers / client.py View on Github external
def rebuild(self, server, image):
        # type: (servers.domain.Server, Image) -> actions.domainAction
        """Rebuilds a server overwriting its disk with the content of an image, thereby destroying all data on the target server.

        :param server: :class:`BoundServer ` or :class:`Server `
        :param image: :class:`BoundImage ` or :class:`Image `
        :return:  :class:`BoundAction `
        """
        data = {
            "image": image.id_or_name
        }
        response = self._client.request(url="/servers/{server_id}/actions/rebuild".format(server_id=server.id),
                                        method="POST", json=data)
        return BoundAction(self._client.actions, response['action'])
github hetznercloud / hcloud-python / hcloud / load_balancers / client.py View on Github external
def disable_public_interface(self, load_balancer):
        # type: (Union[LoadBalancer, BoundLoadBalancer]) -> BoundAction
        """ Disables the public interface of a Load Balancer.

        :param load_balancer: :class:` ` or :class:`LoadBalancer `

        :return: :class:`BoundAction `
        """

        response = self._client.request(
            url="/load_balancers/{load_balancer_id}/actions/disable_public_interface".format(
                load_balancer_id=load_balancer.id),
            method="POST")
        return BoundAction(self._client.actions, response['action'])
github hetznercloud / hcloud-python / hcloud / servers / client.py View on Github external
"""Changes the alias IPs of an already attached network.

        :param server: :class:`BoundServer ` or :class:`Server `
        :param network: :class:`BoundNetwork ` or :class:`Network `
        :param alias_ips: List[str]
                New alias IPs to set for this server.
        :return: :class:`BoundAction `
        """
        data = {
            "network": network.id,
            "alias_ips": alias_ips
        }
        response = self._client.request(
            url="/servers/{server_id}/actions/change_alias_ips".format(server_id=server.id), method="POST",
            json=data)
        return BoundAction(self._client.actions, response['action'])
github hetznercloud / hcloud-python / hcloud / floating_ips / client.py View on Github external
# type: (FloatingIP, Optional[bool]) -> BoundAction
        """Changes the protection configuration of the Floating IP.

        :param floating_ip: :class:`BoundFloatingIP ` or  :class:`FloatingIP `
        :param delete: boolean
               If true, prevents the Floating IP from being deleted
        :return: :class:`BoundAction `
        """
        data = {}
        if delete is not None:
            data.update({"delete": delete})

        response = self._client.request(
            url="/floating_ips/{floating_ip_id}/actions/change_protection".format(floating_ip_id=floating_ip.id),
            method="POST", json=data)
        return BoundAction(self._client.actions, response['action'])
github hetznercloud / hcloud-python / hcloud / load_balancers / client.py View on Github external
def change_algorithm(self, load_balancer, algorithm):
        # type: (Union[LoadBalancer, BoundLoadBalancer], Optional[bool]) -> BoundAction
        """Changes the algorithm used by the Load Balancer

        :param load_balancer: :class:` ` or :class:`LoadBalancer `
        :param algorithm: :class:`LoadBalancerAlgorithm `
                       The LoadBalancerSubnet you want to add to the Load Balancer
        :return: :class:`BoundAction `
        """
        data = {"type": algorithm.type}

        response = self._client.request(
            url="/load_balancers/{load_balancer_id}/actions/change_algorithm".format(load_balancer_id=load_balancer.id),
            method="POST", json=data)
        return BoundAction(self._client.actions, response['action'])
github hetznercloud / hcloud-python / hcloud / volumes / client.py View on Github external
def detach(self, volume):
        # type: (Union[Volume, BoundVolume]) -> BoundAction
        """Detaches a volume from the server it’s attached to. You may attach it to a server again at a later time.

        :param volume: :class:`BoundVolume ` or :class:`Volume `
        :return: :class:`BoundAction `
        """
        data = self._client.request(url="/volumes/{volume_id}/actions/detach".format(volume_id=volume.id),
                                    method="POST")
        return BoundAction(self._client.actions, data['action'])
github hetznercloud / hcloud-python / hcloud / load_balancers / client.py View on Github external
:param load_balancer: :class:`BoundLoadBalancer ` or :class:`LoadBalancer `
        :param target: :class:`LoadBalancerTarget `
                       The LoadBalancerTarget you want to add to the Load Balancer
        :return: :class:`BoundAction `
        """
        data = {
            "type": target.type,
            "server": {"id": target.server.id},
            "use_private_ip": target.use_private_ip
        }

        response = self._client.request(
            url="/load_balancers/{load_balancer_id}/actions/add_target".format(load_balancer_id=load_balancer.id),
            method="POST", json=data)
        return BoundAction(self._client.actions, response['action'])
github hetznercloud / hcloud-python / hcloud / servers / client.py View on Github external
IP to request to be assigned to this server
        :param alias_ips: List[str]
                New alias IPs to set for this server.
        :return: :class:`BoundAction `
        """
        data = {
            "network": network.id,
        }
        if ip is not None:
            data.update({"ip": ip})
        if alias_ips is not None:
            data.update({"alias_ips": alias_ips})
        response = self._client.request(
            url="/servers/{server_id}/actions/attach_to_network".format(server_id=server.id), method="POST",
            json=data)
        return BoundAction(self._client.actions, response['action'])