Skip to content

Commit

Permalink
Added notification profiles functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
NodePing committed Mar 23, 2022
1 parent efc58e2 commit 9058c42
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 1 deletion.
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file.

(Placeholder for unreleased content)

## [1.5.0]

2022-03-23

### Added

- notification profile create/get/update/delete https://nodeping.com/docs-api-notificationprofiles.html

## [1.4.1]

2022-01-13
Expand Down
126 changes: 126 additions & 0 deletions nodeping_api/notificationprofiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Manage notification profiles for NodePing Account.
https://nodeping.com/docs-api-notificationprofiles.html
"""

from . import _query_nodeping_api, _utils, config

API_URL = "{0}notificationprofiles".format(config.API_URL)


def get(token,
customerid=None,
id=None):
"""Get one or all notification profiles for an account or subaccount.
:param token: The NodePing token for your account
:type token: str
:param customerid: (optional) ID for the subaccount
:type customerid: str
:param id: (optional) - id of the notification profile you want to get.
"""
if id:
url = "{0}?id={1}".format(API_URL, id)
else:
url = API_URL

url = _utils.create_url(token, url, customerid)

return _query_nodeping_api.get(url)


def create(token,
name,
notifications,
customerid=None):
"""Create a new notification profile.
:param token: The NodePing token for your account
:type token: str
:param name: label for the notification profile
:type name: str
:param notifications: list containing the contact or group id, delay, and scheduling for notifications
:type notifications: list
:param customerid: (optional) ID for the subaccount
:type customerid: str
notifications param example:
[
{"contactkey1":
{"delay":0,
"schedule":"schedule1"
}
},
{"contactkey2":
{"delay":5,
"schedule":"schedule2"
}
}
]
"""
url = _utils.create_url(token, API_URL, customerid)
data = {"notifications": notifications, "name": name}

return _query_nodeping_api.post(url, data)


def update(token,
name,
id,
notifications,
customerid=None):
"""Update information for a contact profile.
:param token: The NodePing token for your account
:type token: str
:param name: label for the notification profile
:type name: str
:param id: notification profile id you want to modify
:type id: str
:param notifications: list containing the contact or group id, delay, and scheduling for notifications
:type notifications: list
:param customerid: (optional) ID for the subaccount
:type customerid: str
notifications param example:
[
{"contactkey1":
{"delay":0,
"schedule":"schedule1"
}
},
{"contactkey2":
{"delay":5,
"schedule":"schedule2"
}
}
]
"""
url = _utils.create_url(token, API_URL, customerid)
data = {"notifications": notifications, "name": name, "id": id}

return _query_nodeping_api.put(url, data)


def delete(token,
id,
customerid=None):
"""Get one or all notification profiles for an account or subaccount.
:param token: The NodePing token for your account
:type token: str
:param customerid: (optional) ID for the subaccount
:type customerid: str
:param id: (optional) - id of the notification profile you want to get.
"""
url = "{0}/{1}".format(API_URL, id)

url = _utils.create_url(token, url, customerid)

return _query_nodeping_api.delete(url)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
URL = "https://github.com/NodePing/python-nodeping-api"
EMAIL = "[email protected]"
AUTHOR = "NodePing"
VERSION = "1.4.1"
VERSION = "1.5.0"
LICENSE = "MIT"

setuptools.setup(
Expand Down

0 comments on commit 9058c42

Please sign in to comment.