-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauditlog.py
More file actions
64 lines (48 loc) · 2.29 KB
/
auditlog.py
File metadata and controls
64 lines (48 loc) · 2.29 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""This class takes a base URL as an argument when it's initialized,
which is the endpoint for the RESTFUL API that we'll be interacting with.
The create(), read(), update(), and delete() methods each correspond to
the CRUD operations that can be performed on the API """
from ..common import Parameter
from .._errors import ArgumentException
from .._messages import LOG_ITEM_UID_REQUIRED
class Auditlog(Parameter):
"""
This class takes a base URL as an argument when it's initialized,
which is the endpoint for the RESTFUL API that
we'll be interacting with. The create(), read(), update(), and delete()
methods each correspond to the CRUD
operations that can be performed on the API """
def __init__(self, client, log_item_uid: str):
self.client = client
self.log_item_uid = log_item_uid
super().__init__(self.client)
self.path = "audit-logs"
def find(self):
"""
The "Get audit log" request is used to retrieve the audit log of a stack.
:return: Json, with auditlog details.
-------------------------------
[Example:]
>>> import contentstack_management
>>> client = contentstack_management.Client(authtoken='your_authtoken')
>>> result = client.stack("api_key").auditlog().find().json()
-------------------------------
"""
return self.client.get(self.path, headers = self.client.headers, params = self.params)
def fetch(self):
"""
The "Get audit log item" request is used to retrieve a specific item from the audit log of a stack.
:return: Json, with auditlog details.
-------------------------------
[Example:]
>>> import contentstack_management
>>> client = contentstack_management.Client(authtoken='your_authtoken')
>>> result = client.stack('api_key').auditlog('log_item_uid').fetch().json()
-------------------------------
"""
self.validate_uid()
url = f"{self.path}/{self.log_item_uid}"
return self.client.get(url, headers = self.client.headers, params = self.params)
def validate_uid(self):
if self.log_item_uid is None or '':
raise ArgumentException(LOG_ITEM_UID_REQUIRED)