How to use the hcloud.core.domain.add_meta_to_result 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 / core / test_client.py View on Github external
def get_actions_list(self, status, page=None, per_page=None):
                    json_content = json_content_function(page)
                    results = [(r, page, status, per_page) for r in json_content['actions']]
                    return add_meta_to_result(results, json_content, 'actions')
            return CandiesClient(mock.MagicMock())
github hetznercloud / hcloud-python / tests / unit / core / test_domain.py View on Github external
def test_add_meta_to_result(self):
        json_content = {
            "meta": {
                "pagination": {
                    "page": 2,
                    "per_page": 10,
                    "previous_page": 1,
                    "next_page": 3,
                    "last_page": 10,
                    "total_entries": 100
                }
            }
        }
        result = add_meta_to_result([1, 2, 3], json_content, "id_list")
        assert result.id_list == [1, 2, 3]
        assert result.meta.pagination.page == 2
        assert result.meta.pagination.per_page == 10
        assert result.meta.pagination.next_page == 3
        assert result.meta.pagination.last_page == 10
        assert result.meta.pagination.total_entries == 100
github hetznercloud / hcloud-python / hcloud / networks / client.py View on Github external
params["sort"] = sort
        if page is not None:
            params["page"] = page
        if per_page is not None:
            params["per_page"] = per_page

        response = self._client.request(
            url="/networks/{network_id}/actions".format(network_id=network.id),
            method="GET",
            params=params,
        )
        actions = [
            BoundAction(self._client.actions, action_data)
            for action_data in response["actions"]
        ]
        return add_meta_to_result(actions, response, "actions")
github hetznercloud / hcloud-python / hcloud / floating_ips / client.py View on Github external
:return: (List[:class:`BoundAction `], :class:`Meta `)
        """
        params = {}
        if status is not None:
            params["status"] = status
        if sort is not None:
            params["sort"] = sort
        if page is not None:
            params["page"] = page
        if per_page is not None:
            params["per_page"] = per_page
        response = self._client.request(
            url="/floating_ips/{floating_ip_id}/actions".format(floating_ip_id=floating_ip.id), method="GET",
            params=params)
        actions = [BoundAction(self._client.actions, action_data) for action_data in response['actions']]
        return add_meta_to_result(actions, response, 'actions')
github hetznercloud / hcloud-python / hcloud / servers / client.py View on Github external
:return: (List[:class:`BoundAction `], :class:`Meta `)
        """
        params = {}
        if status is not None:
            params["status"] = status
        if sort is not None:
            params["sort"] = sort
        if page is not None:
            params["page"] = page
        if per_page is not None:
            params["per_page"] = per_page

        response = self._client.request(url="/servers/{server_id}/actions".format(server_id=server.id), method="GET",
                                        params=params)
        actions = [BoundAction(self._client.actions, action_data) for action_data in response['actions']]
        return add_meta_to_result(actions, response, 'actions')
github hetznercloud / hcloud-python / hcloud / volumes / client.py View on Github external
:return: (List[:class:`BoundAction `], :class:`Meta `)
        """
        params = {}
        if status is not None:
            params["status"] = status
        if sort is not None:
            params["sort"] = sort
        if page is not None:
            params["page"] = page
        if per_page is not None:
            params["per_page"] = per_page

        response = self._client.request(url="/volumes/{volume_id}/actions".format(volume_id=volume.id), method="GET",
                                        params=params)
        actions = [BoundAction(self._client.actions, action_data) for action_data in response['actions']]
        return add_meta_to_result(actions, response, 'actions')
github hetznercloud / hcloud-python / hcloud / images / client.py View on Github external
:param per_page: int (optional)
               Specifies how many results are returned by page
        :return: (List[:class:`BoundAction `], :class:`Meta `)
        """
        params = {}
        if sort is not None:
            params["sort"] = sort
        if status is not None:
            params["status"] = status
        if page is not None:
            params["page"] = page
        if per_page is not None:
            params["per_page"] = per_page
        response = self._client.request(url="/images/{image_id}/actions".format(image_id=image.id), method="GET", params=params)
        actions = [BoundAction(self._client.actions, action_data) for action_data in response['actions']]
        return add_meta_to_result(actions, response, 'actions')
github hetznercloud / hcloud-python / hcloud / load_balancers / client.py View on Github external
params["sort"] = sort
        if page is not None:
            params["page"] = page
        if per_page is not None:
            params["per_page"] = per_page

        response = self._client.request(
            url="/load_balancers/{load_balancer_id}/actions".format(load_balancer_id=load_balancer.id),
            method="GET",
            params=params,
        )
        actions = [
            BoundAction(self._client.actions, action_data)
            for action_data in response["actions"]
        ]
        return add_meta_to_result(actions, response, "actions")