88 BugoutScope ,
99 BugoutScopes ,
1010 BugoutJournalScopeSpecs ,
11+ BugoutJournalEntry ,
12+ BugoutJournalEntries ,
1113 HolderType ,
1214 Method ,
1315)
@@ -28,59 +30,6 @@ def _call(self, method: Method, path: str, **kwargs):
2830 result = make_request (method = method , url = url , ** kwargs )
2931 return result
3032
31- # Journal module
32- def create_journal (self , token : uuid .UUID , name : str ) -> BugoutJournal :
33- journal_path = "journals/"
34- json = {
35- "name" : name ,
36- }
37- headers = {
38- "Authorization" : f"Bearer { token } " ,
39- }
40- result = self ._call (
41- method = Method .post , path = journal_path , headers = headers , json = json
42- )
43- return BugoutJournal (** result )
44-
45- def list_journals (self , token : uuid .UUID ) -> BugoutJournals :
46- journal_path = "journals/"
47- headers = {
48- "Authorization" : f"Bearer { token } " ,
49- }
50- result = self ._call (method = Method .get , path = journal_path , headers = headers )
51- return BugoutJournals (** result )
52-
53- def get_journal (self , token : uuid .UUID , journal_id : uuid .UUID ) -> BugoutJournal :
54- journal_id_path = f"journals/{ journal_id } "
55- headers = {
56- "Authorization" : f"Bearer { token } " ,
57- }
58- result = self ._call (method = Method .get , path = journal_id_path , headers = headers )
59- return BugoutJournal (** result )
60-
61- def update_journal (
62- self , token : uuid .UUID , journal_id : uuid .UUID , name : str
63- ) -> BugoutJournal :
64- journal_id_path = f"journals/{ journal_id } "
65- json = {
66- "name" : name ,
67- }
68- headers = {
69- "Authorization" : f"Bearer { token } " ,
70- }
71- result = self ._call (
72- method = Method .put , path = journal_id_path , headers = headers , json = json
73- )
74- return BugoutJournal (** result )
75-
76- def delete_journal (self , token : uuid .UUID , journal_id : uuid .UUID ) -> BugoutJournal :
77- journal_id_path = f"journals/{ journal_id } "
78- headers = {
79- "Authorization" : f"Bearer { token } " ,
80- }
81- result = self ._call (method = Method .delete , path = journal_id_path , headers = headers )
82- return BugoutJournal (** result )
83-
8433 # Scope module
8534 def list_scopes (self , token : uuid .UUID , api : str ) -> BugoutScopes :
8635 scopes_path = f"journals/scopes"
@@ -151,3 +100,107 @@ def delete_journal_scopes(
151100 method = Method .delete , path = journal_scopes_path , headers = headers , json = json
152101 )
153102 return BugoutJournalScopeSpecs (** result )
103+
104+ # Journal module
105+ def create_journal (self , token : uuid .UUID , name : str ) -> BugoutJournal :
106+ journal_path = "journals/"
107+ json = {
108+ "name" : name ,
109+ }
110+ headers = {
111+ "Authorization" : f"Bearer { token } " ,
112+ }
113+ result = self ._call (
114+ method = Method .post , path = journal_path , headers = headers , json = json
115+ )
116+ return BugoutJournal (** result )
117+
118+ def list_journals (self , token : uuid .UUID ) -> BugoutJournals :
119+ journal_path = "journals/"
120+ headers = {
121+ "Authorization" : f"Bearer { token } " ,
122+ }
123+ result = self ._call (method = Method .get , path = journal_path , headers = headers )
124+ return BugoutJournals (** result )
125+
126+ def get_journal (self , token : uuid .UUID , journal_id : uuid .UUID ) -> BugoutJournal :
127+ journal_id_path = f"journals/{ journal_id } "
128+ headers = {
129+ "Authorization" : f"Bearer { token } " ,
130+ }
131+ result = self ._call (method = Method .get , path = journal_id_path , headers = headers )
132+ return BugoutJournal (** result )
133+
134+ def update_journal (
135+ self , token : uuid .UUID , journal_id : uuid .UUID , name : str
136+ ) -> BugoutJournal :
137+ journal_id_path = f"journals/{ journal_id } "
138+ json = {
139+ "name" : name ,
140+ }
141+ headers = {
142+ "Authorization" : f"Bearer { token } " ,
143+ }
144+ result = self ._call (
145+ method = Method .put , path = journal_id_path , headers = headers , json = json
146+ )
147+ return BugoutJournal (** result )
148+
149+ def delete_journal (self , token : uuid .UUID , journal_id : uuid .UUID ) -> BugoutJournal :
150+ journal_id_path = f"journals/{ journal_id } "
151+ headers = {
152+ "Authorization" : f"Bearer { token } " ,
153+ }
154+ result = self ._call (method = Method .delete , path = journal_id_path , headers = headers )
155+ return BugoutJournal (** result )
156+
157+ # Entry module
158+ def create_entry (
159+ self ,
160+ token : uuid .UUID ,
161+ journal_id : uuid .UUID ,
162+ title : str ,
163+ content : str ,
164+ tags : List [str ] = [],
165+ context_url : Optional [str ] = None ,
166+ context_id : Optional [str ] = None ,
167+ context_type : Optional [str ] = None ,
168+ ) -> BugoutJournalEntry :
169+ journal_entry_path = f"journals/{ journal_id } /entries"
170+ json = {
171+ "title" : title ,
172+ "content" : content ,
173+ "tags" : tags ,
174+ "context_url" : context_url ,
175+ "context_id" : context_id ,
176+ "context_type" : context_type ,
177+ }
178+ headers = {
179+ "Authorization" : f"Bearer { token } " ,
180+ }
181+ result = self ._call (
182+ method = Method .post , path = journal_entry_path , headers = headers , json = json
183+ )
184+ return BugoutJournalEntry (** result )
185+
186+ def get_entry (
187+ self , token : uuid .UUID , journal_id : uuid .UUID , entry_id : uuid .UUID
188+ ) -> BugoutJournalEntry :
189+ journal_entry_id_path = f"journals/{ journal_id } /entries/{ entry_id } "
190+ headers = {
191+ "Authorization" : f"Bearer { token } " ,
192+ }
193+ result = self ._call (
194+ method = Method .get , path = journal_entry_id_path , headers = headers
195+ )
196+ return BugoutJournalEntry (** result )
197+
198+ def get_entries (
199+ self , token : uuid .UUID , journal_id : uuid .UUID
200+ ) -> BugoutJournalEntries :
201+ journal_entry_path = f"journals/{ journal_id } /entries"
202+ headers = {
203+ "Authorization" : f"Bearer { token } " ,
204+ }
205+ result = self ._call (method = Method .get , path = journal_entry_path , headers = headers )
206+ return BugoutJournalEntries (** result )
0 commit comments