From 4866a0efab2914afed6a634233d36be9f19a5e52 Mon Sep 17 00:00:00 2001 From: Eric Kao Date: Tue, 11 Jul 2017 00:49:14 -0700 Subject: [PATCH] Add client methods for library policy CRUD Not yet integrated into or tested with OSC CLI. Client methods put in place first to allow GUI dev to proceed. Partial-Bug: 1693623 Partially implements: blueprint policy-library Change-Id: Ib94dd4de6242faeb29756f43afaa05621b7df1ac --- congressclient/v1/client.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/congressclient/v1/client.py b/congressclient/v1/client.py index 1d428d4..1bd0ce1 100644 --- a/congressclient/v1/client.py +++ b/congressclient/v1/client.py @@ -43,6 +43,9 @@ class Client(object): policy_rows_trace = '/v1/policies/%s/tables/%s/rows?trace=True' policies = '/v1/policies' policy_action = '/v1/policies/%s?%s' + library_policy = '/v1/librarypolicies' + library_policy_path = '/v1/librarypolicies/%s' + library_policies = '/v1/librarypolicies' datasources = '/v1/data-sources' datasource_path = '/v1/data-sources/%s' datasource_tables = '/v1/data-sources/%s/tables' @@ -77,6 +80,21 @@ class Client(object): self.policy_path % policy) return body + def create_library_policy(self, body): + resp, body = self.httpclient.post( + self.library_policy, body=body) + return body + + def delete_library_policy(self, policy): + resp, body = self.httpclient.delete( + self.library_policy_path % policy) + return body + + def show_library_policy(self, policy): + resp, body = self.httpclient.get( + self.library_policy_path % policy) + return body + def create_policy_rule(self, policy_name, body=None): resp, body = self.httpclient.post( self.policy_rules % policy_name, body=body) @@ -108,6 +126,10 @@ class Client(object): resp, body = self.httpclient.get(self.policies) return body + def list_library_policy(self): + resp, body = self.httpclient.get(self.library_policies) + return body + def list_policy_tables(self, policy_name): resp, body = self.httpclient.get(self.policy_tables % (policy_name)) return body