def add_webhooks_links(policies, gid): for policy in policies: webhook_list = [_format_webhook(webhook_model, self.tenant_id, gid, policy['id']) for webhook_model in policy['webhooks']] policy['webhooks'] = webhook_list policy['webhooks_links'] = get_webhooks_links( webhook_list, self.tenant_id, gid, policy['id'], rel='webhooks')
def test_get_webhooks_links(self): """ `get_webhooks_links` gets link from `get_autoscale_links` and delegates to get_collection_links """ links = get_webhooks_links('webhooks', 'tid', 'gid', 'pid', rel='rel', limit=2, marker='3') self.assertEqual(links, 'col links') self.gal.assert_called_once_with('tid', 'gid', 'pid', '', format=None) self.gcl.assert_called_once_with('webhooks', 'url', 'rel', 2, '3')
def format_webhooks(webhook_list): webhook_list = [_format_webhook(webhook_model, self.tenant_id, self.group_id, self.policy_id) for webhook_model in webhook_list] return { 'webhooks': webhook_list, "webhooks_links": get_webhooks_links( webhook_list, self.tenant_id, self.group_id, self.policy_id, None, **paginate) }
def add_webhooks_links(policies): for policy in policies: webhook_list = [_format_webhook(webhook_model, self.tenant_id, self.group_id, policy['id']) for webhook_model in policy['webhooks']] policy['webhooks'] = webhook_list policy['webhooks_links'] = get_webhooks_links( webhook_list, self.tenant_id, self.group_id, policy['id'], rel='webhooks')
def format_webhooks(webhook_list): webhook_list = [ _format_webhook(webhook_model, self.tenant_id, self.group_id, self.policy_id) for webhook_model in webhook_list ] return { 'webhooks': webhook_list, "webhooks_links": get_webhooks_links(webhook_list, self.tenant_id, self.group_id, self.policy_id, None, **paginate) }