Skip to content

Commit

Permalink
Add period Item(), update docstring and API doc
Browse files Browse the repository at this point in the history
Ref #246
  • Loading branch information
algorys committed Feb 28, 2018
1 parent c11ca36 commit 5761f56
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 10 deletions.
2 changes: 1 addition & 1 deletion alignak_app/items/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""
Daemon
++++++
Daemon manage creation of daemon item
Daemon manage creation of daemon item for backend ``alignakdaemon`` endpoint
"""


Expand Down
2 changes: 1 addition & 1 deletion alignak_app/items/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""
Event
+++++
Event manage creation of notification item
Event manage creation of event item (Notifications collected from ``history`` endpoint)
"""

import datetime
Expand Down
2 changes: 1 addition & 1 deletion alignak_app/items/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""
History
+++++++
History manage creation of history item
History manage creation of history item for backend ``history`` endpoint
"""

from logging import getLogger
Expand Down
2 changes: 1 addition & 1 deletion alignak_app/items/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""
Host
++++
Host manage creation of host item
Host manage creation of host item for backend ``host`` endpoint
"""

import json
Expand Down
4 changes: 2 additions & 2 deletions alignak_app/items/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""
Item
++++
Item is parent class for all models
Item is parent class for all items objects
"""


Expand All @@ -33,7 +33,7 @@

class Item(object):
"""
Class who create item
Class who create an item
"""

def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion alignak_app/items/livesynthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""
Live Synthesis
++++++++++++++
Livesynthesis manage creation of livesynthesis item
Livesynthesis manage creation of livesynthesis item for backend ``livesynthesis`` endpoint
"""


Expand Down
77 changes: 77 additions & 0 deletions alignak_app/items/period.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2015-2018:
# Matthieu Estrada, [email protected]
#
# This file is part of (AlignakApp).
#
# (AlignakApp) is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# (AlignakApp) is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with (AlignakApp). If not, see <http://www.gnu.org/licenses/>.

"""
Period
++++++
Period manage creation of period item for backend ``timeperiod`` endpoint
"""


from logging import getLogger

from alignak_app.items.item import Item

logger = getLogger(__name__)


class Period(Item):
"""
Class who create a period item
"""

def __init__(self):
super(Period, self).__init__()
self.item_type = 'timeperiod'

@staticmethod
def get_request_model():
"""
Return the request model for alignakdaemon requests

:return: request model for alignakdaemon endpoint
:rtype: dict
"""

realms_projection = [
'name', 'alias'
]

request_model = {
'endpoint': 'timeperiod',
'params': None,
'projection': realms_projection
}

return request_model

def get_display_name(self):
"""
Return alias or name if available

:return: name or alias
:rtype: str
"""

if 'alias' in self.data:
return self.data['alias'].title()

return self.data['name'].title()
2 changes: 1 addition & 1 deletion alignak_app/items/realm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

class Realm(Item):
"""
Class who create a daemon item
Class who create a realm item
"""

def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion alignak_app/items/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""
Service
+++++++
Service manage creation of service item
Service manage creation of service item for backend ``service`` endpoint
"""

import json
Expand Down
2 changes: 1 addition & 1 deletion alignak_app/items/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

class User(Item):
"""
Class who create user item
Class who create user item for backend ``user`` endpoint
"""

def __init__(self):
Expand Down
5 changes: 5 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ Items
:inherited-members:
:show-inheritance:

.. automodule:: alignak_app.items.period
:members:
:inherited-members:
:show-inheritance:

.. automodule:: alignak_app.items.realm
:members:
:inherited-members:
Expand Down

0 comments on commit 5761f56

Please sign in to comment.