Skip to content

Commit f55031f

Browse files
committed
API updates.
1 parent 99108cf commit f55031f

File tree

3 files changed

+102
-2
lines changed

3 files changed

+102
-2
lines changed

src/moeralib/node/node.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,32 @@ def delete_node_name(self) -> types.Result:
12021202
data = self.call("delete_node_name", location, method="DELETE", schema=schemas.RESULT_SCHEMA)
12031203
return types.Result.from_json(data)
12041204

1205+
def get_stored_mnemonic(self) -> types.KeyMnemonic:
1206+
"""
1207+
Get the updating key mnemonic stored on the node.
1208+
"""
1209+
location = "/node-name/mnemonic"
1210+
data = self.call("get_stored_mnemonic", location, method="GET", schema=schemas.KEY_MNEMONIC_SCHEMA)
1211+
return types.KeyMnemonic.from_json(data)
1212+
1213+
def store_mnemonic(self, mnemonic: types.KeyMnemonic) -> types.Result:
1214+
"""
1215+
Store the updating key mnemonic on the node.
1216+
1217+
:param mnemonic:
1218+
"""
1219+
location = "/node-name/mnemonic"
1220+
data = self.call("store_mnemonic", location, method="POST", body=mnemonic, schema=schemas.RESULT_SCHEMA)
1221+
return types.Result.from_json(data)
1222+
1223+
def delete_stored_mnemonic(self) -> types.Result:
1224+
"""
1225+
Delete the updating key mnemonic stored on the node.
1226+
"""
1227+
location = "/node-name/mnemonic"
1228+
data = self.call("delete_stored_mnemonic", location, method="DELETE", schema=schemas.RESULT_SCHEMA)
1229+
return types.Result.from_json(data)
1230+
12051231
def send_notification(self, packet: types.NotificationPacket) -> types.Result:
12061232
"""
12071233
Accept a notification packet from another node. Notification packets older than 10 minutes are ignored. The
@@ -2075,6 +2101,16 @@ def update_story(self, id: str, story: types.StoryAttributes) -> types.StoryInfo
20752101
)
20762102
return types.StoryInfo.from_json(data)
20772103

2104+
def delete_story(self, id: str) -> types.Result:
2105+
"""
2106+
Delete the story.
2107+
2108+
:param id: ID of the story
2109+
"""
2110+
location = "/stories/{id}".format(id=quote_plus(id))
2111+
data = self.call("delete_story", location, method="DELETE", schema=schemas.RESULT_SCHEMA)
2112+
return types.Result.from_json(data)
2113+
20782114
def get_subscribers(
20792115
self, node_name: str | None = None, type: types.SubscriptionType | None = None, feed_name: str | None = None,
20802116
entry_id: str | None = None

src/moeralib/node/schemas.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,22 @@
939939

940940
GRANT_INFO_ARRAY_SCHEMA = array_schema(GRANT_INFO_SCHEMA)
941941

942+
KEY_MNEMONIC_SCHEMA: Any = {
943+
"type": "object",
944+
"properties": {
945+
"mnemonic": {
946+
"type": "array",
947+
"items": {
948+
"type": "string"
949+
}
950+
},
951+
},
952+
"required": [
953+
"mnemonic",
954+
],
955+
"additionalProperties": False
956+
}
957+
942958
LINK_PREVIEW_SCHEMA: Any = {
943959
"type": "object",
944960
"properties": {
@@ -1028,6 +1044,9 @@
10281044
"operationErrorMessage": {
10291045
"type": ["string", "null"]
10301046
},
1047+
"storedMnemonic": {
1048+
"type": ["boolean", "null"]
1049+
},
10311050
"operations": to_nullable_object_schema(NODE_NAME_OPERATIONS_SCHEMA),
10321051
},
10331052
"additionalProperties": False
@@ -1923,6 +1942,26 @@
19231942
"additionalProperties": False
19241943
}
19251944

1945+
STORY_SUMMARY_PAGE_CLICKS_SCHEMA: Any = {
1946+
"type": "object",
1947+
"properties": {
1948+
"heading": {
1949+
"type": ["string", "null"]
1950+
},
1951+
"href": {
1952+
"type": "string"
1953+
},
1954+
"clicks": {
1955+
"type": "integer"
1956+
},
1957+
},
1958+
"required": [
1959+
"href",
1960+
"clicks",
1961+
],
1962+
"additionalProperties": False
1963+
}
1964+
19261965
STORY_SUMMARY_REACTION_SCHEMA: Any = {
19271966
"type": "object",
19281967
"properties": {
@@ -2796,6 +2835,10 @@
27962835
"description": {
27972836
"type": ["string", "null"]
27982837
},
2838+
"clicks": {
2839+
"type": ["array", "null"],
2840+
"items": STORY_SUMMARY_PAGE_CLICKS_SCHEMA
2841+
},
27992842
},
28002843
"additionalProperties": False
28012844
}

src/moeralib/node/types.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
"all": 0x3fffffff,
7474
}
7575

76+
SearchEngine = Literal["google"]
77+
7678
SettingType = Literal[
7779
"bool", "int", "string", "json", "Duration", "PrivateKey", "PublicKey", "Timestamp", "UUID", "Principal"
7880
]
@@ -88,7 +90,7 @@
8890
"unlawful", "defamatory", "threat", "spam", "scam", "malware", "copyright", "impersonating", "privacy", "other"
8991
]
9092

91-
SourceFormat = Literal["plain-text", "html", "markdown", "application"]
93+
SourceFormat = Literal["plain-text", "html", "markdown", "html/visual", "application"]
9294

9395
StoryType = Literal[
9496
"asked-to-friend", "asked-to-subscribe", "blocked-user", "blocked-user-in-posting", "comment-added",
@@ -99,7 +101,8 @@
99101
"posting-media-reaction-added-negative", "posting-media-reaction-added-positive", "posting-media-reaction-failed",
100102
"posting-post-task-failed", "posting-reaction-task-failed", "posting-subscribe-task-failed",
101103
"posting-update-task-failed", "posting-updated", "reaction-added-negative", "reaction-added-positive",
102-
"remote-comment-added", "reply-comment", "sheriff-complaint-added", "sheriff-complaint-decided", "sheriff-marked",
104+
"reminder-avatar", "reminder-email", "reminder-full-name", "reminder-sheriff-allow", "remote-comment-added",
105+
"reply-comment", "search-report", "sheriff-complaint-added", "sheriff-complaint-decided", "sheriff-marked",
103106
"sheriff-unmarked", "subscriber-added", "subscriber-deleted", "unblocked-user", "unblocked-user-in-posting"
104107
]
105108

@@ -1148,6 +1151,11 @@ class GrantInfo(Structure):
11481151
"""the set of administrative permissions granted to the node"""
11491152

11501153

1154+
class KeyMnemonic(Structure):
1155+
mnemonic: List[str]
1156+
"""the words"""
1157+
1158+
11511159
class LinkPreview(Structure):
11521160
site_name: str | None = None
11531161
"""name of the site"""
@@ -1234,6 +1242,8 @@ class NodeNameInfo(Structure):
12341242
"""if the operation with the node name was failed, the code of the failure"""
12351243
operation_error_message: str | None = None
12361244
"""if the operation with the node name was failed, the human-readable description of the failure"""
1245+
stored_mnemonic: bool | None = None
1246+
"""``True``, if updating key mnemonic is being stored on the node, ``False`` otherwise"""
12371247
operations: NodeNameOperations | None = None
12381248
"""the supported operations and the corresponding principals"""
12391249

@@ -1990,6 +2000,15 @@ class StorySummaryNode(Structure):
19902000
"""node owner's gender"""
19912001

19922002

2003+
class StorySummaryPageClicks(Structure):
2004+
heading: str | None = None
2005+
"""page heading, ``None`` for the blog itself"""
2006+
href: str
2007+
"""page URL"""
2008+
clicks: int
2009+
"""number of clicks on the page"""
2010+
2011+
19932012
class StorySummaryReaction(Structure):
19942013
owner_name: str | None = None
19952014
"""reaction owner's name"""
@@ -2805,6 +2824,8 @@ class StorySummaryData(Structure):
28052824
"""summary of an action of a sheriff"""
28062825
description: str | None = None
28072826
"""additional descriptive text"""
2827+
clicks: List[StorySummaryPageClicks] | None = None
2828+
"""list of pages with number of clicks on each of them"""
28082829

28092830

28102831
class CommentInfo(Structure):

0 commit comments

Comments
 (0)