1+ """This class takes a base URL as an argument when it's initialized,
2+ which is the endpoint for the RESTFUL API that we'll be interacting with.
3+ The create(), read(), update(), and delete() methods each correspond to
4+ the CRUD operations that can be performed on the API """
5+
6+ import json
7+ from ..common import Parameter
8+ from urllib .parse import quote
9+ from .._errors import ArgumentException
10+
11+ class Auditlog (Parameter ):
12+ """
13+ This class takes a base URL as an argument when it's initialized,
14+ which is the endpoint for the RESTFUL API that
15+ we'll be interacting with. The create(), read(), update(), and delete()
16+ methods each correspond to the CRUD
17+ operations that can be performed on the API """
18+
19+ def __init__ (self , client , log_item_uid : str ):
20+ self .client = client
21+ self .log_item_uid = log_item_uid
22+ super ().__init__ (self .client )
23+
24+ self .path = "audit-logs"
25+
26+ def find (self ):
27+ """
28+ The "Get audit log" request is used to retrieve the audit log of a stack.
29+ :return: Json, with auditlog details.
30+
31+ -------------------------------
32+ [Example:]
33+
34+ >>> from contentstack_management import contentstack
35+ >>> client = contentstack.client(authtoken='your_authtoken')
36+ >>> result = client.stack("api_key").auditlog().find().json()
37+
38+ -------------------------------
39+ """
40+ return self .client .get (self .path , headers = self .client .headers )
41+
42+
43+
44+ def fetch (self ):
45+ """
46+ The "Get audit log item" request is used to retrieve a specific item from the audit log of a stack.
47+ :return: Json, with auditlog details.
48+ -------------------------------
49+ [Example:]
50+
51+ >>> from contentstack_management import contentstack
52+ >>> client = contentstack.client(authtoken='your_authtoken')
53+ >>> result = client.stack('api_key').auditlog('log_item_uid').fetch().json()
54+
55+ -------------------------------
56+ """
57+ self .validate_uid ()
58+ url = f"{ self .path } /{ self .log_item_uid } "
59+ return self .client .get (url , headers = self .client .headers )
60+
61+ def validate_uid (self ):
62+ if self .log_item_uid is None or '' :
63+ raise ArgumentException ('Log item Uid is required' )
64+
65+
0 commit comments