Skip to content

Commit 848de77

Browse files
authored
Merge pull request #52 from Ethan-Black/add_notification_center_api
Add notification center api
2 parents 1e77505 + d5d8a37 commit 848de77

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed

qingcloud/iaas/connection.py

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4899,3 +4899,163 @@ def describe_resource_user_groups(self,
48994899
return None
49004900

49014901
return self.send_request(action, body)
4902+
4903+
def create_notification_list(self, notification_list_name,
4904+
notification_items,
4905+
**ignore):
4906+
""" Create new notification list.
4907+
@param notification_list_name: the name of the notification list.
4908+
@param notification_items: an array including IDs of the notification items.
4909+
"""
4910+
action = const.ACTION_CREATE_NOTIFICATION_LIST
4911+
valid_keys = ['notification_list_name', 'notification_items']
4912+
body = filter_out_none(locals(), valid_keys)
4913+
if not self.req_checker.check_params(body,
4914+
required_params=['notification_list_name', 'notification_items'],
4915+
list_params=['notification_items']
4916+
):
4917+
return None
4918+
4919+
return self.send_request(action, body)
4920+
4921+
def describe_notification_lists(self, notification_lists=None,
4922+
search_word=None,
4923+
offset=None,
4924+
limit=None,
4925+
**ignore):
4926+
""" Describe notification lists filtered by condition.
4927+
@param notification_lists: an array including the IDs of the notification lists.
4928+
@param search_word: the search word of notification list name.
4929+
@param offset: the starting offset of the returning results.
4930+
@param limit: specify the number of the returning results.
4931+
"""
4932+
action = const.ACTION_DESCRIBE_NOTIFICATION_LISTS
4933+
valid_keys = ['notification_lists', 'search_word', 'offset', 'limit']
4934+
body = filter_out_none(locals(), valid_keys)
4935+
if not self.req_checker.check_params(body,
4936+
required_params=[],
4937+
integer_params=['offset', 'limit'],
4938+
list_params=['notification_lists']):
4939+
return None
4940+
4941+
return self.send_request(action, body)
4942+
4943+
def modify_notification_list_attributes(self, notification_list,
4944+
notification_list_name=None,
4945+
notification_items=None,
4946+
**ignore):
4947+
""" Modify notification list attributes.
4948+
@param notification_list: The ID of notification list which attributes you want to modify.
4949+
@param notification_list_name: The new name of the notification list which will be modified.
4950+
@param notification_items: An array including IDs of notification items.
4951+
"""
4952+
action = const.ACTION_MODIFY_NOTIFICATION_LIST_ATTRIBUTES
4953+
valid_keys = ['notification_list', 'notification_list_name', 'notification_items']
4954+
body = filter_out_none(locals(), valid_keys)
4955+
if not self.req_checker.check_params(body,
4956+
required_params=['notification_list'],
4957+
integer_params=[],
4958+
list_params=['notification_items']
4959+
):
4960+
return None
4961+
4962+
return self.send_request(action, body)
4963+
4964+
def delete_notification_lists(self, notification_lists,
4965+
**ignore):
4966+
""" Delete one or more notification lists.
4967+
the notification list will not be deleted along with the notification items.
4968+
@param notification_lists: An array including IDs of the notification lists which you want to delete.
4969+
"""
4970+
action = const.ACTION_DELETE_NOTIFICATION_LISTS
4971+
valid_keys = ['notification_lists']
4972+
body = filter_out_none(locals(), valid_keys)
4973+
if not self.req_checker.check_params(body,
4974+
required_params=['notification_lists'],
4975+
integer_params=[],
4976+
list_params=['notification_lists']
4977+
):
4978+
return None
4979+
4980+
return self.send_request(action, body)
4981+
4982+
def create_notification_items(self, notification_items,
4983+
**ignore):
4984+
""" Create new notification items.
4985+
@param notification_items: The message of notification items,each item in the array is an Object,
4986+
including 'content','notification_item_type' and 'remarks'.
4987+
"""
4988+
action = const.ACTION_CREATE_NOTIFICATION_ITEMS
4989+
valid_keys = ['notification_items']
4990+
body = filter_out_none(locals(), valid_keys)
4991+
if not self.req_checker.check_params(body,
4992+
required_params=['notification_items'],
4993+
integer_params=[],
4994+
list_params=['notification_items']
4995+
):
4996+
return None
4997+
4998+
return self.send_request(action, body)
4999+
5000+
def describe_notification_items(self,
5001+
notification_items=None,
5002+
notification_list=None,
5003+
notification_item_type=None,
5004+
offset=None,
5005+
limit=None,
5006+
**ignore):
5007+
""" Describe notification items filtered by condition.
5008+
@param notification_items: An array including IDs of notification items.
5009+
@param notification_list: The ID of notification list.
5010+
@param notification_item_type: The type of notification item, including 'email', 'phone' and 'webhook'.
5011+
@param offset: the starting offset of the returning results.
5012+
@param limit: specify the number of the returning results.
5013+
"""
5014+
action = const.ACTION_DESCRIBE_NOTIFICATION_ITEMS
5015+
valid_keys = ['notification_items', 'notification_list', 'notification_item_type', 'offset', 'limit']
5016+
body = filter_out_none(locals(), valid_keys)
5017+
if not self.req_checker.check_params(body,
5018+
integer_params=['offset', 'limit'],
5019+
list_params=['notification_items']
5020+
):
5021+
return None
5022+
5023+
return self.send_request(action, body)
5024+
5025+
def delete_notification_items(self, notification_items,
5026+
**ignore):
5027+
""" Delete one or more notification items.
5028+
@param notification_items: An array including IDs of the notification items which you want to delete.
5029+
"""
5030+
action = const.ACTION_DELETE_NOTIFICATION_ITEMS
5031+
valid_keys = ['notification_items']
5032+
body = filter_out_none(locals(), valid_keys)
5033+
if not self.req_checker.check_params(body,
5034+
required_params=['notification_items'],
5035+
integer_params=[],
5036+
list_params=['notification_items']
5037+
):
5038+
return None
5039+
5040+
return self.send_request(action, body)
5041+
5042+
def verify_notification_item(self,
5043+
notification_item_content,
5044+
verification_code,
5045+
**ignore):
5046+
""" Verify the notification item.
5047+
All notification items need to be verified to receive notifications.
5048+
@param notification_item_content: The content of notification item which will be verified.
5049+
@param verification_code: The verification code.
5050+
"""
5051+
action = const.ACTION_VERIFY_NOTIFICATION_ITEM
5052+
valid_keys = ['notification_item_content','verification_code']
5053+
body = filter_out_none(locals(), valid_keys)
5054+
if not self.req_checker.check_params(body,
5055+
required_params=['notification_item_content','verification_code'],
5056+
integer_params=[],
5057+
list_params=[]
5058+
):
5059+
return None
5060+
5061+
return self.send_request(action, body)

qingcloud/iaas/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818

1919
# Notification Center
2020
ACTION_DESCRIBE_NOTIFICATION_CENTER_USER_POSTS = "DescribeNotificationCenterUserPosts"
21+
ACTION_CREATE_NOTIFICATION_LIST = "CreateNotificationList"
22+
ACTION_DESCRIBE_NOTIFICATION_LISTS = "DescribeNotificationLists"
23+
ACTION_MODIFY_NOTIFICATION_LIST_ATTRIBUTES = "ModifyNotificationListAttributes"
24+
ACTION_DELETE_NOTIFICATION_LISTS = "DeleteNotificationLists"
25+
ACTION_CREATE_NOTIFICATION_ITEMS = "CreateNotificationItems"
26+
ACTION_DESCRIBE_NOTIFICATION_ITEMS = "DescribeNotificationItems"
27+
ACTION_DELETE_NOTIFICATION_ITEMS = "DeleteNotificationItems"
28+
ACTION_VERIFY_NOTIFICATION_ITEM = "VerifyNotificationItem"
2129

2230
# zones
2331
ACTION_DESCRIBE_ZONES = "DescribeZones"

0 commit comments

Comments
 (0)