aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_db/moon_db/api/pdp.py
blob: 05eb163f6835f2467dc7dd2a40fd3876b90cf4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
# This software is distributed under the terms and conditions of the 'Apache-2.0'
# license which can be found in the file 'LICENSE' in this package distribution
# or at 'http://www.apache.org/licenses/LICENSE-2.0'.

from uuid import uuid4
from oslo_log import log as logging
from moon_utilities.security_functions import filter_input, enforce
from moon_db.api.managers import Managers


LOG = logging.getLogger("moon.db.api.pdp")


class PDPManager(Managers):

    def __init__(self, connector=None):
        self.driver = connector.driver
        Managers.PDPManager = self

    @enforce(("read", "write"), "pdp")
    def update_pdp(self, user_id, pdp_id, value):
        return self.driver.update_pdp(pdp_id=pdp_id, value=value)

    @enforce(("read", "write"), "pdp")
    def delete_pdp(self, user_id, pdp_id):
        return self.driver.delete_pdp(pdp_id=pdp_id)

    @enforce(("read", "write"), "pdp")
    def add_pdp(self, user_id, pdp_id=None, value=None):
        if not pdp_id:
            pdp_id = uuid4().hex
        return self.driver.add_pdp(pdp_id=pdp_id, value=value)

    @enforce("read", "pdp")
    def get_pdp(self, user_id, pdp_id=None):
        return self.driver.get_pdp(pdp_id=pdp_id)