Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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())
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
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")
: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')
: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')
: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')
: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')
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")