Add config object
Change-Id: I480dc21c50557b16a46b971862cefdb23c157a2c
This commit is contained in:
parent
5f6b765f53
commit
fafec7f3fd
@ -0,0 +1,135 @@
|
||||
# Copyright 2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
|
||||
|
||||
class TestBusinessImpactModulations(clienttest.ClientTest):
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:5311/v2/config/"
|
||||
"businessimpactmodulations",
|
||||
body='[{"business_impact": 1,'
|
||||
'"business_impact_modulation_name": "LowImpactOnDay",'
|
||||
'"modulation_period": "day"},'
|
||||
'{"business_impact": 1,'
|
||||
'"business_impact_modulation_name": "LowImpactOnNight",'
|
||||
'"modulation_period": "night"}]'
|
||||
|
||||
)
|
||||
|
||||
businessimpactmodulations = (self.client.config.
|
||||
businessimpactmodulations.list())
|
||||
|
||||
self.assertEqual(
|
||||
businessimpactmodulations,
|
||||
[{"business_impact": 1,
|
||||
"business_impact_modulation_name": "LowImpactOnDay",
|
||||
"modulation_period": "day"},
|
||||
{"business_impact": 1,
|
||||
"business_impact_modulation_name": "LowImpactOnNight",
|
||||
"modulation_period": "night"}, ]
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_create(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, "http://localhost:5311/v2/config/"
|
||||
"businessimpactmodulations",
|
||||
body='{"business_impact": 1,'
|
||||
'"business_impact_modulation_name": "testtt",'
|
||||
'"modulation_period": "day"}'
|
||||
)
|
||||
|
||||
self.client.config.businessimpactmodulations.create(
|
||||
business_impact=1,
|
||||
business_impact_modulation_name="testtt",
|
||||
modulation_period="day"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"business_impact": 1,
|
||||
"business_impact_modulation_name": "testtt",
|
||||
"modulation_period": "day"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/businessimpactmodulations/'
|
||||
'LowImpactOnDay',
|
||||
body='{"business_impact": 1,'
|
||||
'"business_impact_modulation_name": "LowImpactOnDay",'
|
||||
'"modulation_period": "day"}'
|
||||
)
|
||||
|
||||
businessimpactmodulation = (
|
||||
self.client.config.businessimpactmodulations.get(
|
||||
businessimpactmodulation_name='LowImpactOnDay')
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
businessimpactmodulation,
|
||||
{"business_impact": 1,
|
||||
"business_impact_modulation_name": "LowImpactOnDay",
|
||||
"modulation_period": "day"}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/businessimpactmodulations/'
|
||||
'LowImpactOnNight',
|
||||
body='{"test": "test"}'
|
||||
)
|
||||
|
||||
self.client.config.businessimpactmodulations.update(
|
||||
businessimpactmodulation_name="LowImpactOnNight",
|
||||
businessimpactmodulation={'modulation_period': 'night'}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"modulation_period": u"night"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_delete(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.DELETE,
|
||||
"http://localhost:5311/v2/config/businessimpactmodulations/"
|
||||
"name_to_delete",
|
||||
body="body"
|
||||
)
|
||||
|
||||
body = self.client.config.businessimpactmodulations.delete(
|
||||
businessimpactmodulation_name="name_to_delete",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
@ -44,7 +44,7 @@ class TestCheckModulations(clienttest.ClientTest):
|
||||
httpretty.GET, "http://localhost:5311/v2/config/checkmodulations",
|
||||
body='[{"checkmodulation_name": "test","check_command": "test",'
|
||||
'"check_period": "test"}]'
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
self.client.config.checkmodulations.list(),
|
||||
@ -66,4 +66,45 @@ class TestCheckModulations(clienttest.ClientTest):
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/checkmodulations/ping_night',
|
||||
body='{"checkmodulation_name": "ping_night",'
|
||||
'"check_command": "check_ping_night",'
|
||||
'"check_period": "night"}'
|
||||
)
|
||||
|
||||
checkmodulation = self.client.config.checkmodulations.get(
|
||||
checkmodulation_name='ping_night'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
checkmodulation,
|
||||
{"checkmodulation_name": "ping_night",
|
||||
"check_command": "check_ping_night",
|
||||
"check_period": "night"}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/checkmodulations/ping_night',
|
||||
body='{"check_command": "updated"}'
|
||||
)
|
||||
|
||||
self.client.config.checkmodulations.update(
|
||||
checkmodulation_name='ping_night',
|
||||
checkmodulation={"check_command": "updated"}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"check_command": u"updated"
|
||||
}
|
||||
)
|
||||
|
@ -55,7 +55,7 @@ class TestCommands(clienttest.ClientTest):
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_show(self):
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
"http://localhost:5311/v2/config/commands/command_to_show",
|
||||
|
121
surveilclient/tests/v2_0/config/test_contactgroups.py
Normal file
121
surveilclient/tests/v2_0/config/test_contactgroups.py
Normal file
@ -0,0 +1,121 @@
|
||||
# Copyright 2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
|
||||
|
||||
class TestContactGroups(clienttest.ClientTest):
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:5311/v2/config/contactgroups",
|
||||
body='[{"contactgroup_name": "novell-admins",'
|
||||
'"members": "jdoe,rtobert,tzach"},'
|
||||
'{"contactgroup_name": "linux-adminx",'
|
||||
'"members": "linus,richard"}]'
|
||||
)
|
||||
|
||||
contactgroups = self.client.config.contactgroups.list()
|
||||
|
||||
self.assertEqual(
|
||||
contactgroups,
|
||||
[{"contactgroup_name": "novell-admins",
|
||||
"members": "jdoe,rtobert,tzach"},
|
||||
{"contactgroup_name": "linux-adminx",
|
||||
"members": "linus,richard"},
|
||||
]
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_create(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, "http://localhost:5311/v2/config/contactgroups",
|
||||
body='{"contactgroup_name": "John",'
|
||||
'"members": "marie,bob,joe"}'
|
||||
)
|
||||
|
||||
self.client.config.contactgroups.create(
|
||||
contactgroup_name='John',
|
||||
members="marie,bob,joe"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"contactgroup_name": "John",
|
||||
"members": "marie,bob,joe"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/contactgroups/novell-admins',
|
||||
body='{"contactgroup_name": "novell-admins",'
|
||||
'"members": "jdoe,rtobert,tzach"}'
|
||||
)
|
||||
|
||||
contactgroup = self.client.config.contactgroups.get(
|
||||
contactgroup_name='novell-admins'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
contactgroup,
|
||||
{
|
||||
'contactgroup_name': 'novell-admins',
|
||||
'members': 'jdoe,rtobert,tzach'
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/contactgroups/novell-admins',
|
||||
body='{"test": "test"}'
|
||||
)
|
||||
|
||||
self.client.config.contactgroups.update(
|
||||
contactgroup_name="novell-admins",
|
||||
contactgroup={"members": "updated"}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"members": u"updated"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_delete(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.DELETE,
|
||||
"http://localhost:5311/v2/config/contactgroups/novell-admins",
|
||||
body="body"
|
||||
)
|
||||
|
||||
body = self.client.config.contactgroups.delete(
|
||||
contactgroup_name="novell-admins",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
124
surveilclient/tests/v2_0/config/test_contacts.py
Normal file
124
surveilclient/tests/v2_0/config/test_contacts.py
Normal file
@ -0,0 +1,124 @@
|
||||
# Copyright 2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
|
||||
|
||||
class TestContacts(clienttest.ClientTest):
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:5311/v2/config/contacts",
|
||||
body='[{"contact_name": "bobby",'
|
||||
'"email": "bob@bob.com"},'
|
||||
'{"contact_name": "marie",'
|
||||
'"email": "marie@marie.com"}]'
|
||||
)
|
||||
|
||||
contacts = self.client.config.contacts.list()
|
||||
|
||||
self.assertEqual(
|
||||
contacts,
|
||||
[
|
||||
{
|
||||
'contact_name': 'bobby',
|
||||
'email': 'bob@bob.com'
|
||||
},
|
||||
{
|
||||
'contact_name': 'marie',
|
||||
'email': 'marie@marie.com'
|
||||
},
|
||||
]
|
||||
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_create(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, "http://localhost:5311/v2/config/contacts",
|
||||
body='{"contact_name": "John"}'
|
||||
)
|
||||
|
||||
self.client.config.contacts.create(
|
||||
contact_name='John'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"contact_name": "John"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/contacts/bobby',
|
||||
body='{"contact_name": "bobby",'
|
||||
'"email": "bob@bob.com"}'
|
||||
)
|
||||
|
||||
contact = self.client.config.contacts.get(
|
||||
contact_name='bobby'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
contact,
|
||||
{
|
||||
'contact_name': 'bobby',
|
||||
'email': 'bob@bob.com'
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/contacts/bob',
|
||||
body='{"test": "test"}'
|
||||
)
|
||||
|
||||
self.client.config.contacts.update(
|
||||
contact_name="bob",
|
||||
contact={"email": "updated"}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"email": u"updated"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_delete(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.DELETE,
|
||||
"http://localhost:5311/v2/config/contacts/bob",
|
||||
body="body"
|
||||
)
|
||||
|
||||
body = self.client.config.contacts.delete(
|
||||
contact_name="bob",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
126
surveilclient/tests/v2_0/config/test_hostgroups.py
Normal file
126
surveilclient/tests/v2_0/config/test_hostgroups.py
Normal file
@ -0,0 +1,126 @@
|
||||
# Copyright 2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
|
||||
|
||||
class TestHostGroups(clienttest.ClientTest):
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:5311/v2/config/hostgroups",
|
||||
body='[{"hostgroup_name": "novell-servers",'
|
||||
'"members": "netware1,netware2,netware3,netware4"},'
|
||||
'{"hostgroup_name": "otherservers",'
|
||||
'"members": "googul,sfl"}]'
|
||||
)
|
||||
|
||||
hostgroups = self.client.config.hostgroups.list()
|
||||
|
||||
self.assertEqual(
|
||||
hostgroups,
|
||||
[
|
||||
{
|
||||
'hostgroup_name': 'novell-servers',
|
||||
'members': 'netware1,netware2,netware3,netware4',
|
||||
},
|
||||
{
|
||||
'hostgroup_name': 'otherservers',
|
||||
'members': 'googul,sfl',
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_create(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, "http://localhost:5311/v2/config/hostgroups",
|
||||
body='{"hostgroup_name": "John",'
|
||||
'"members": "marie,bob,joe"}'
|
||||
)
|
||||
|
||||
self.client.config.hostgroups.create(
|
||||
hostgroup_name='John',
|
||||
members="marie,bob,joe"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"hostgroup_name": "John",
|
||||
"members": "marie,bob,joe"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/hostgroups/novell-servers',
|
||||
body='{"hostgroup_name": "novell-servers",'
|
||||
'"members": "netware1,netware2,netware3,netware4"}'
|
||||
)
|
||||
|
||||
hostgroup = self.client.config.hostgroups.get(
|
||||
hostgroup_name='novell-servers'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
hostgroup,
|
||||
{
|
||||
'hostgroup_name': 'novell-servers',
|
||||
'members': 'netware1,netware2,netware3,netware4'
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/hostgroups/novell-servers',
|
||||
body='{"test": "test"}'
|
||||
)
|
||||
|
||||
self.client.config.hostgroups.update(
|
||||
hostgroup_name="novell-servers",
|
||||
hostgroup={"members": "updated"}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"members": u"updated"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_delete(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.DELETE,
|
||||
"http://localhost:5311/v2/config/hostgroups/novell-servers",
|
||||
body="body"
|
||||
)
|
||||
|
||||
body = self.client.config.hostgroups.delete(
|
||||
hostgroup_name="novell-servers",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
@ -69,7 +69,7 @@ class TestHosts(clienttest.ClientTest):
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_show(self):
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
"http://localhost:5311/v2/config/hosts/host_name_to_show",
|
||||
|
134
surveilclient/tests/v2_0/config/test_macromodulations.py
Normal file
134
surveilclient/tests/v2_0/config/test_macromodulations.py
Normal file
@ -0,0 +1,134 @@
|
||||
# Copyright 2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
|
||||
|
||||
class TestMacroModulations(clienttest.ClientTest):
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:5311/v2/config/macromodulations",
|
||||
body='[{"macromodulation_name": "HighDuringNight",'
|
||||
'"modulation_period": "night",'
|
||||
'"_CRITICAL": 20,'
|
||||
'"_WARNING": 10},'
|
||||
'{"macromodulation_name": "LowDuringNight",'
|
||||
'"modulation_period": "night",'
|
||||
'"_CRITICAL": 10,'
|
||||
'"_WARNING": 20}]'
|
||||
)
|
||||
|
||||
contacts = self.client.config.macromodulations.list()
|
||||
|
||||
self.assertEqual(
|
||||
contacts,
|
||||
[
|
||||
{
|
||||
'macromodulation_name': 'HighDuringNight',
|
||||
'modulation_period': 'night',
|
||||
'_CRITICAL': 20,
|
||||
'_WARNING': 10,
|
||||
},
|
||||
{
|
||||
'macromodulation_name': 'LowDuringNight',
|
||||
'modulation_period': 'night',
|
||||
'_CRITICAL': 10,
|
||||
'_WARNING': 20,
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_create(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, "http://localhost:5311/v2/config/macromodulations",
|
||||
body='{"macromodulation_name": "TEST_CREATE_MODULATION",'
|
||||
'"modulation_period": "night"}'
|
||||
)
|
||||
|
||||
self.client.config.macromodulations.create(
|
||||
macromodulation_name='TEST_CREATE_MODULATION',
|
||||
modulation_period='night'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"macromodulation_name": "TEST_CREATE_MODULATION",
|
||||
"modulation_period": "night"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/macromodulations/HighDuringNight',
|
||||
body='{"macromodulation_name": "HighDuringNight",'
|
||||
'"modulation_period": "night"}'
|
||||
)
|
||||
|
||||
macromodulation = self.client.config.macromodulations.get(
|
||||
macromodulation_name='HighDuringNight'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
macromodulation,
|
||||
{
|
||||
'macromodulation_name': 'HighDuringNight',
|
||||
'modulation_period': 'night'
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/macromodulations/HighDuringNight',
|
||||
body='{"test": "test"}'
|
||||
)
|
||||
|
||||
self.client.config.macromodulations.update(
|
||||
macromodulation_name="HighDuringNight",
|
||||
macromodulation={"modulation_period": "updated"}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"modulation_period": u"updated"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_delete(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.DELETE,
|
||||
"http://localhost:5311/v2/config/macromodulations/test",
|
||||
body="body"
|
||||
)
|
||||
|
||||
body = self.client.config.macromodulations.delete(
|
||||
macromodulation_name="test",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
187
surveilclient/tests/v2_0/config/test_notificationways.py
Normal file
187
surveilclient/tests/v2_0/config/test_notificationways.py
Normal file
@ -0,0 +1,187 @@
|
||||
# Copyright 2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
|
||||
|
||||
class TestNotificationWays(clienttest.ClientTest):
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:5311/v2/config/notificationways",
|
||||
body='[{'
|
||||
'"notificationway_name": "email_in_day",'
|
||||
'"host_notification_period": "24x7",'
|
||||
'"service_notification_period": "24x7",'
|
||||
'"host_notification_options": "d,u",'
|
||||
'"service_notification_options": "w,c,r",'
|
||||
'"host_notification_commands": "notify-service",'
|
||||
'"service_notification_commands": "notify-host"'
|
||||
'},'
|
||||
'{'
|
||||
'"notificationway_name": "email_all_time",'
|
||||
'"host_notification_period": "24x7",'
|
||||
'"service_notification_period": "24x7",'
|
||||
'"host_notification_options": "d,r,f,u",'
|
||||
'"service_notification_options": "w,f,c,r",'
|
||||
'"host_notification_commands": "notify-service",'
|
||||
'"service_notification_commands": "notify-host",'
|
||||
'"min_business_impact": 5'
|
||||
'}'
|
||||
']'
|
||||
)
|
||||
|
||||
notificationways = self.client.config.notificationways.list()
|
||||
|
||||
self.assertEqual(
|
||||
notificationways,
|
||||
[
|
||||
{
|
||||
'notificationway_name': 'email_in_day',
|
||||
'host_notification_period': '24x7',
|
||||
'service_notification_period': '24x7',
|
||||
'host_notification_options': 'd,u',
|
||||
'service_notification_options': 'w,c,r',
|
||||
'host_notification_commands': 'notify-service',
|
||||
'service_notification_commands': 'notify-host'
|
||||
},
|
||||
{
|
||||
'notificationway_name': 'email_all_time',
|
||||
'host_notification_period': '24x7',
|
||||
'service_notification_period': '24x7',
|
||||
'host_notification_options': 'd,r,f,u',
|
||||
'service_notification_options': 'w,f,c,r',
|
||||
'host_notification_commands': 'notify-service',
|
||||
'service_notification_commands': 'notify-host',
|
||||
'min_business_impact': 5
|
||||
}
|
||||
]
|
||||
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_create(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, "http://localhost:5311/v2/config/notificationways",
|
||||
body='{'
|
||||
'"notificationway_name": "email_in_day",'
|
||||
'"host_notification_period": "24x7",'
|
||||
'"service_notification_period": "24x7",'
|
||||
'"host_notification_options": "d,u",'
|
||||
'"service_notification_options": "w,c,r",'
|
||||
'"host_notification_commands": "notify-service",'
|
||||
'"service_notification_commands": "notify-host"'
|
||||
'}'
|
||||
)
|
||||
|
||||
self.client.config.notificationways.create(
|
||||
notificationway_name='test_create_notification',
|
||||
host_notification_period='24x7',
|
||||
service_notification_period='24x7',
|
||||
host_notification_options='d,r,f,u',
|
||||
service_notification_options='w,f,c,r',
|
||||
host_notification_commands='notify-service',
|
||||
service_notification_commands='notify-host',
|
||||
min_business_impact=5
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
'notificationway_name': 'test_create_notification',
|
||||
'host_notification_period': '24x7',
|
||||
'service_notification_period': '24x7',
|
||||
'host_notification_options': 'd,r,f,u',
|
||||
'service_notification_options': 'w,f,c,r',
|
||||
'host_notification_commands': 'notify-service',
|
||||
'service_notification_commands': 'notify-host',
|
||||
'min_business_impact': 5
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/notificationways/email_all_time',
|
||||
body='{'
|
||||
'"notificationway_name": "email_all_time",'
|
||||
'"host_notification_period": "24x7",'
|
||||
'"service_notification_period": "24x7",'
|
||||
'"host_notification_options": "d,r,f,u",'
|
||||
'"service_notification_options": "w,f,c,r",'
|
||||
'"host_notification_commands": "notify-service",'
|
||||
'"service_notification_commands": "notify-host",'
|
||||
'"min_business_impact": 5'
|
||||
'}'
|
||||
)
|
||||
|
||||
notificationway = self.client.config.notificationways.get(
|
||||
notificationway_name='email_all_time'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
notificationway,
|
||||
{
|
||||
'notificationway_name': 'email_all_time',
|
||||
'host_notification_period': '24x7',
|
||||
'service_notification_period': '24x7',
|
||||
'host_notification_options': 'd,r,f,u',
|
||||
'service_notification_options': 'w,f,c,r',
|
||||
'host_notification_commands': 'notify-service',
|
||||
'service_notification_commands': 'notify-host',
|
||||
'min_business_impact': 5
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/notificationways/email_all_time',
|
||||
body='{"test": "test"}'
|
||||
)
|
||||
|
||||
self.client.config.notificationways.update(
|
||||
notificationway_name="email_all_time",
|
||||
notificationway={"host_notification_period": "updated"}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"host_notification_period": u"updated"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_delete(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.DELETE,
|
||||
"http://localhost:5311/v2/config/notificationways/bob",
|
||||
body="body"
|
||||
)
|
||||
|
||||
body = self.client.config.notificationways.delete(
|
||||
notificationway_name="bob",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
144
surveilclient/tests/v2_0/config/test_realms.py
Normal file
144
surveilclient/tests/v2_0/config/test_realms.py
Normal file
@ -0,0 +1,144 @@
|
||||
# Copyright 2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
|
||||
|
||||
class TestRealms(clienttest.ClientTest):
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:5311/v2/config/realms",
|
||||
body='['
|
||||
'{'
|
||||
'"realm_name": "World",'
|
||||
'"realm_members": "Europe,America,Asia",'
|
||||
'"default": 0'
|
||||
'},'
|
||||
'{'
|
||||
'"realm_name": "Anti-world",'
|
||||
'"realm_members": "void,black-hole",'
|
||||
'"default": 1'
|
||||
'}'
|
||||
']'
|
||||
)
|
||||
|
||||
realms = self.client.config.realms.list()
|
||||
|
||||
self.assertEqual(
|
||||
realms,
|
||||
[
|
||||
{
|
||||
'realm_name': 'World',
|
||||
'realm_members': 'Europe,America,Asia',
|
||||
'default': 0
|
||||
},
|
||||
{
|
||||
'realm_name': 'Anti-world',
|
||||
'realm_members': 'void,black-hole',
|
||||
'default': 1
|
||||
},
|
||||
]
|
||||
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_create(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, "http://localhost:5311/v2/config/realms",
|
||||
body='{"realm_name": "John",'
|
||||
'"realm_members":"marie,bob,joe",'
|
||||
'"default":1}'
|
||||
)
|
||||
|
||||
self.client.config.realms.create(
|
||||
realm_name='John',
|
||||
realm_members="marie,bob,joe",
|
||||
default=1
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"realm_name": "John",
|
||||
"realm_members": "marie,bob,joe",
|
||||
"default": 1
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/realms/bobby',
|
||||
body='{'
|
||||
'"realm_name": "World",'
|
||||
'"realm_members": "Europe,America,Asia",'
|
||||
'"default": 0'
|
||||
'}'
|
||||
)
|
||||
|
||||
realm = self.client.config.realms.get(
|
||||
realm_name='bobby'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
realm,
|
||||
{
|
||||
'realm_name': 'World',
|
||||
'realm_members': 'Europe,America,Asia',
|
||||
'default': 0
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/realms/World',
|
||||
body='{"test": "test"}'
|
||||
)
|
||||
|
||||
self.client.config.realms.update(
|
||||
realm_name="World",
|
||||
realm={"realm_members": "updated"}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"realm_members": u"updated"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_delete(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.DELETE,
|
||||
"http://localhost:5311/v2/config/realms/bob",
|
||||
body="body"
|
||||
)
|
||||
|
||||
body = self.client.config.realms.delete(
|
||||
realm_name="bob",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
129
surveilclient/tests/v2_0/config/test_servicegroups.py
Normal file
129
surveilclient/tests/v2_0/config/test_servicegroups.py
Normal file
@ -0,0 +1,129 @@
|
||||
# Copyright 2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
|
||||
|
||||
class TestServiceGroups(clienttest.ClientTest):
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:5311/v2/config/servicegroups",
|
||||
body='[{"servicegroup_name": "dbservices",'
|
||||
'"members": "ms1,SQL Server,ms1,'
|
||||
'SQL Serverc Agent,ms1,SQL DTC"},'
|
||||
'{"servicegroup_name": "otherservices",'
|
||||
'"members": "some,other,member"}]'
|
||||
)
|
||||
|
||||
servicegroups = self.client.config.servicegroups.list()
|
||||
|
||||
self.assertEqual(
|
||||
servicegroups,
|
||||
[
|
||||
{
|
||||
'servicegroup_name': 'dbservices',
|
||||
'members': 'ms1,SQL Server,ms1,'
|
||||
'SQL Serverc Agent,ms1,SQL DTC',
|
||||
},
|
||||
{
|
||||
'servicegroup_name': 'otherservices',
|
||||
'members': 'some,other,member',
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_create(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, "http://localhost:5311/v2/config/servicegroups",
|
||||
body='{"servicegroup_name": "John",'
|
||||
'"members": "marie,bob,joe"}'
|
||||
)
|
||||
|
||||
self.client.config.servicegroups.create(
|
||||
servicegroup_name='John',
|
||||
members="marie,bob,joe"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"servicegroup_name": "John",
|
||||
"members": "marie,bob,joe"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/servicegroups/dbservices',
|
||||
body='{"servicegroup_name": "dbservices",'
|
||||
'"members": "ms1,SQL Server,ms1,'
|
||||
'SQL Serverc Agent,ms1,SQL DTC"}'
|
||||
)
|
||||
|
||||
servicegroup = self.client.config.servicegroups.get(
|
||||
servicegroup_name='dbservices'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
servicegroup,
|
||||
{
|
||||
'servicegroup_name': 'dbservices',
|
||||
'members': 'ms1,SQL Server,ms1,SQL Serverc Agent,ms1,SQL DTC'
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/servicegroups/dbservices',
|
||||
body='{"test": "test"}'
|
||||
)
|
||||
|
||||
self.client.config.servicegroups.update(
|
||||
servicegroup_name="dbservices",
|
||||
servicegroup={"members": "updated"}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"members": u"updated"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_delete(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.DELETE,
|
||||
"http://localhost:5311/v2/config/servicegroups/dbservices",
|
||||
body="body"
|
||||
)
|
||||
|
||||
body = self.client.config.servicegroups.delete(
|
||||
servicegroup_name="dbservices",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
139
surveilclient/tests/v2_0/config/test_timeperiods.py
Normal file
139
surveilclient/tests/v2_0/config/test_timeperiods.py
Normal file
@ -0,0 +1,139 @@
|
||||
# Copyright 2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
|
||||
|
||||
class TestTimePeriods(clienttest.ClientTest):
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:5311/v2/config/timeperiods",
|
||||
body='['
|
||||
'{'
|
||||
'"timeperiod_name": "nonworkhours",'
|
||||
'"sunday": "00:00-24:00",'
|
||||
'"monday": "00:00-09:00,17:00-24:00"'
|
||||
'},'
|
||||
'{'
|
||||
'"timeperiod_name": "misc-single-days",'
|
||||
'"1999-01-28": "00:00-24:00",'
|
||||
'"day 2": "00:00-24:00"'
|
||||
'}'
|
||||
']'
|
||||
|
||||
)
|
||||
|
||||
timeperiods = self.client.config.timeperiods.list()
|
||||
|
||||
self.assertEqual(
|
||||
timeperiods,
|
||||
[
|
||||
{
|
||||
'timeperiod_name': 'nonworkhours',
|
||||
'sunday': '00:00-24:00',
|
||||
'monday': '00:00-09:00,17:00-24:00'
|
||||
},
|
||||
{
|
||||
'timeperiod_name': 'misc-single-days',
|
||||
'1999-01-28': '00:00-24:00',
|
||||
'day 2': '00:00-24:00',
|
||||
},
|
||||
]
|
||||
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_create(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, "http://localhost:5311/v2/config/timeperiods",
|
||||
body='{"timeperiod_name": "John"}'
|
||||
)
|
||||
|
||||
self.client.config.timeperiods.create(
|
||||
timeperiod_name='new_periods'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"timeperiod_name": "new_periods"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'http://localhost:5311/v2/config/timeperiods/nonworkhours',
|
||||
body='{'
|
||||
'"timeperiod_name": "nonworkhours",'
|
||||
'"sunday": "00:00-24:00",'
|
||||
'"monday": "00:00-09:00,17:00-24:00"'
|
||||
'}'
|
||||
)
|
||||
|
||||
timeperiod = self.client.config.timeperiods.get(
|
||||
timeperiod_name='nonworkhours'
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
timeperiod,
|
||||
{
|
||||
'timeperiod_name': 'nonworkhours',
|
||||
'sunday': '00:00-24:00',
|
||||
'monday': '00:00-09:00,17:00-24:00'
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_update(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.PUT,
|
||||
'http://localhost:5311/v2/config/timeperiods/nonworkhours',
|
||||
body='{"test": "test"}'
|
||||
)
|
||||
|
||||
self.client.config.timeperiods.update(
|
||||
timeperiod_name="nonworkhours",
|
||||
timeperiod={"timeperiod_name": "updated"}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"timeperiod_name": u"updated"
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_delete(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.DELETE,
|
||||
"http://localhost:5311/v2/config/timeperiods/bob",
|
||||
body="body"
|
||||
)
|
||||
|
||||
body = self.client.config.timeperiods.delete(
|
||||
timeperiod_name="bob",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
body,
|
||||
"body"
|
||||
)
|
@ -13,10 +13,19 @@
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
from surveilclient.v2_0.config import businessimpactmodulations
|
||||
from surveilclient.v2_0.config import checkmodulations
|
||||
from surveilclient.v2_0.config import commands
|
||||
from surveilclient.v2_0.config import contactgroups
|
||||
from surveilclient.v2_0.config import contacts
|
||||
from surveilclient.v2_0.config import hostgroups
|
||||
from surveilclient.v2_0.config import hosts
|
||||
from surveilclient.v2_0.config import macromodulations
|
||||
from surveilclient.v2_0.config import notificationways
|
||||
from surveilclient.v2_0.config import realms
|
||||
from surveilclient.v2_0.config import servicegroups
|
||||
from surveilclient.v2_0.config import services
|
||||
from surveilclient.v2_0.config import timeperiods
|
||||
|
||||
|
||||
class ConfigManager(surveil_manager.SurveilManager):
|
||||
@ -24,11 +33,26 @@ class ConfigManager(surveil_manager.SurveilManager):
|
||||
|
||||
def __init__(self, http_client):
|
||||
super(ConfigManager, self).__init__(http_client)
|
||||
self.businessimpactmodulations = (businessimpactmodulations.
|
||||
BusinessImpactModulationsManager(
|
||||
self.http_client))
|
||||
self.checkmodulations = checkmodulations.CheckModulationsManager(
|
||||
self.http_client)
|
||||
self.commands = commands.CommandsManager(self.http_client)
|
||||
self.contacts = contacts.ContactsManager(self.http_client)
|
||||
self.contactgroups = contactgroups.ContactGroupsManager(
|
||||
self.http_client)
|
||||
self.hosts = hosts.HostsManager(self.http_client)
|
||||
self.hostgroups = hostgroups.HostGroupsManager(self.http_client)
|
||||
self.macromodulations = macromodulations.MacroModulationsManager(
|
||||
self.http_client)
|
||||
self.notificationways = notificationways.NotificationWaysManager(
|
||||
self.http_client)
|
||||
self.realms = realms.RealmsManager(self.http_client)
|
||||
self.services = services.ServicesManager(self.http_client)
|
||||
self.servicegroups = servicegroups.ServiceGroupsManager(
|
||||
self.http_client)
|
||||
self.timeperiods = timeperiods.TimePeriodsManager(self.http_client)
|
||||
|
||||
def reload_config(self):
|
||||
resp, body = self.http_client.json_request(
|
||||
|
62
surveilclient/v2_0/config/businessimpactmodulations.py
Normal file
62
surveilclient/v2_0/config/businessimpactmodulations.py
Normal file
@ -0,0 +1,62 @@
|
||||
# Copyright 2014-2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
|
||||
|
||||
class BusinessImpactModulationsManager(surveil_manager.SurveilManager):
|
||||
base_url = '/config/businessimpactmodulations'
|
||||
|
||||
def list(self):
|
||||
"""Get a list of businessimpactmodulations."""
|
||||
resp, body = self.http_client.json_request(
|
||||
BusinessImpactModulationsManager.base_url, 'GET'
|
||||
)
|
||||
return body
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a new businessimpactmodulation."""
|
||||
resp, body = self.http_client.json_request(
|
||||
BusinessImpactModulationsManager.base_url, 'POST',
|
||||
body=kwargs
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, businessimpactmodulation_name):
|
||||
"""Get a new businessimpactmodulation."""
|
||||
resp, body = self.http_client.json_request(
|
||||
BusinessImpactModulationsManager.base_url + '/' +
|
||||
businessimpactmodulation_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, businessimpactmodulation_name, businessimpactmodulation):
|
||||
"""Update a businessimpactmodulation."""
|
||||
resp, body = self.http_client.json_request(
|
||||
BusinessImpactModulationsManager.base_url + '/' +
|
||||
businessimpactmodulation_name, 'PUT',
|
||||
body=businessimpactmodulation
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, businessimpactmodulation_name):
|
||||
"""Delete a businessimpactmodulation."""
|
||||
resp, body = self.http_client.request(
|
||||
BusinessImpactModulationsManager.base_url+"/" +
|
||||
businessimpactmodulation_name,
|
||||
'DELETE',
|
||||
body=''
|
||||
)
|
||||
return body
|
@ -33,6 +33,24 @@ class CheckModulationsManager(surveil_manager.SurveilManager):
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, checkmodulation_name):
|
||||
"""Get a new checkmodulation."""
|
||||
resp, body = self.http_client.json_request(
|
||||
CheckModulationsManager.base_url + '/' +
|
||||
checkmodulation_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, checkmodulation_name, checkmodulation):
|
||||
"""Update a checkmodulation."""
|
||||
resp, body = self.http_client.json_request(
|
||||
CheckModulationsManager.base_url + '/' +
|
||||
checkmodulation_name, 'PUT',
|
||||
body=checkmodulation
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, checkmodulation_name):
|
||||
"""Delete a checkmodulation."""
|
||||
resp, body = self.http_client.request(
|
||||
|
59
surveilclient/v2_0/config/contactgroups.py
Normal file
59
surveilclient/v2_0/config/contactgroups.py
Normal file
@ -0,0 +1,59 @@
|
||||
# Copyright 2014-2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
|
||||
|
||||
class ContactGroupsManager(surveil_manager.SurveilManager):
|
||||
base_url = '/config/contactgroups'
|
||||
|
||||
def list(self):
|
||||
"""Get a list of contactgroups."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ContactGroupsManager.base_url, 'GET'
|
||||
)
|
||||
return body
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a new contactgroup."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ContactGroupsManager.base_url, 'POST',
|
||||
body=kwargs
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, contactgroup_name):
|
||||
"""Get a new contactgroup."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ContactGroupsManager.base_url + '/' + contactgroup_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, contactgroup_name, contactgroup):
|
||||
"""Update a contactgroup."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ContactGroupsManager.base_url + '/' + contactgroup_name, 'PUT',
|
||||
body=contactgroup
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, contactgroup_name):
|
||||
"""Delete a contactgroup."""
|
||||
resp, body = self.http_client.request(
|
||||
ContactGroupsManager.base_url + "/" + contactgroup_name,
|
||||
'DELETE',
|
||||
body=''
|
||||
)
|
||||
return body
|
59
surveilclient/v2_0/config/contacts.py
Normal file
59
surveilclient/v2_0/config/contacts.py
Normal file
@ -0,0 +1,59 @@
|
||||
# Copyright 2014-2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
|
||||
|
||||
class ContactsManager(surveil_manager.SurveilManager):
|
||||
base_url = '/config/contacts'
|
||||
|
||||
def list(self):
|
||||
"""Get a list of contacts."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ContactsManager.base_url, 'GET'
|
||||
)
|
||||
return body
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a new contact."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ContactsManager.base_url, 'POST',
|
||||
body=kwargs
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, contact_name):
|
||||
"""Get a new contact."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ContactsManager.base_url + '/' + contact_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, contact_name, contact):
|
||||
"""Update a contact."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ContactsManager.base_url + '/' + contact_name, 'PUT',
|
||||
body=contact
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, contact_name):
|
||||
"""Delete a contact."""
|
||||
resp, body = self.http_client.request(
|
||||
ContactsManager.base_url + "/" + contact_name,
|
||||
'DELETE',
|
||||
body=''
|
||||
)
|
||||
return body
|
59
surveilclient/v2_0/config/hostgroups.py
Normal file
59
surveilclient/v2_0/config/hostgroups.py
Normal file
@ -0,0 +1,59 @@
|
||||
# Copyright 2014-2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
|
||||
|
||||
class HostGroupsManager(surveil_manager.SurveilManager):
|
||||
base_url = '/config/hostgroups'
|
||||
|
||||
def list(self):
|
||||
"""Get a list of hostgroups."""
|
||||
resp, body = self.http_client.json_request(
|
||||
HostGroupsManager.base_url, 'GET'
|
||||
)
|
||||
return body
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a new hostgroup."""
|
||||
resp, body = self.http_client.json_request(
|
||||
HostGroupsManager.base_url, 'POST',
|
||||
body=kwargs
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, hostgroup_name):
|
||||
"""Get a new hostgroup."""
|
||||
resp, body = self.http_client.json_request(
|
||||
HostGroupsManager.base_url + '/' + hostgroup_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, hostgroup_name, hostgroup):
|
||||
"""Update a hostgroup."""
|
||||
resp, body = self.http_client.json_request(
|
||||
HostGroupsManager.base_url + '/' + hostgroup_name, 'PUT',
|
||||
body=hostgroup
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, hostgroup_name):
|
||||
"""Delete a hostgroup."""
|
||||
resp, body = self.http_client.request(
|
||||
HostGroupsManager.base_url + "/" + hostgroup_name,
|
||||
'DELETE',
|
||||
body=''
|
||||
)
|
||||
return body
|
61
surveilclient/v2_0/config/macromodulations.py
Normal file
61
surveilclient/v2_0/config/macromodulations.py
Normal file
@ -0,0 +1,61 @@
|
||||
# Copyright 2014-2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
|
||||
|
||||
class MacroModulationsManager(surveil_manager.SurveilManager):
|
||||
base_url = '/config/macromodulations'
|
||||
|
||||
def list(self):
|
||||
"""Get a list of macromodulations."""
|
||||
resp, body = self.http_client.json_request(
|
||||
MacroModulationsManager.base_url, 'GET'
|
||||
)
|
||||
return body
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a new macromodulation."""
|
||||
resp, body = self.http_client.json_request(
|
||||
MacroModulationsManager.base_url, 'POST',
|
||||
body=kwargs
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, macromodulation_name):
|
||||
"""Get a new macromodulation."""
|
||||
resp, body = self.http_client.json_request(
|
||||
MacroModulationsManager.base_url + '/' +
|
||||
macromodulation_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, macromodulation_name, macromodulation):
|
||||
"""Update a macromodulation."""
|
||||
resp, body = self.http_client.json_request(
|
||||
MacroModulationsManager.base_url + '/' +
|
||||
macromodulation_name, 'PUT',
|
||||
body=macromodulation
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, macromodulation_name):
|
||||
"""Delete a macromodulation."""
|
||||
resp, body = self.http_client.request(
|
||||
MacroModulationsManager.base_url + "/" + macromodulation_name,
|
||||
'DELETE',
|
||||
body=''
|
||||
)
|
||||
return body
|
61
surveilclient/v2_0/config/notificationways.py
Normal file
61
surveilclient/v2_0/config/notificationways.py
Normal file
@ -0,0 +1,61 @@
|
||||
# Copyright 2014-2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
|
||||
|
||||
class NotificationWaysManager(surveil_manager.SurveilManager):
|
||||
base_url = '/config/notificationways'
|
||||
|
||||
def list(self):
|
||||
"""Get a list of notificationways."""
|
||||
resp, body = self.http_client.json_request(
|
||||
NotificationWaysManager.base_url, 'GET'
|
||||
)
|
||||
return body
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a new notificationway."""
|
||||
resp, body = self.http_client.json_request(
|
||||
NotificationWaysManager.base_url, 'POST',
|
||||
body=kwargs
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, notificationway_name):
|
||||
"""Get a new notificationway."""
|
||||
resp, body = self.http_client.json_request(
|
||||
NotificationWaysManager.base_url + '/' +
|
||||
notificationway_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, notificationway_name, notificationway):
|
||||
"""Update a notificationway."""
|
||||
resp, body = self.http_client.json_request(
|
||||
NotificationWaysManager.base_url + '/' +
|
||||
notificationway_name, 'PUT',
|
||||
body=notificationway
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, notificationway_name):
|
||||
"""Delete a command."""
|
||||
resp, body = self.http_client.request(
|
||||
NotificationWaysManager.base_url + "/" + notificationway_name,
|
||||
'DELETE',
|
||||
body=''
|
||||
)
|
||||
return body
|
59
surveilclient/v2_0/config/realms.py
Normal file
59
surveilclient/v2_0/config/realms.py
Normal file
@ -0,0 +1,59 @@
|
||||
# Copyright 2014-2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
|
||||
|
||||
class RealmsManager(surveil_manager.SurveilManager):
|
||||
base_url = '/config/realms'
|
||||
|
||||
def list(self):
|
||||
"""Get a list of realms."""
|
||||
resp, body = self.http_client.json_request(
|
||||
RealmsManager.base_url, 'GET'
|
||||
)
|
||||
return body
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a new realm."""
|
||||
resp, body = self.http_client.json_request(
|
||||
RealmsManager.base_url, 'POST',
|
||||
body=kwargs
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, realm_name):
|
||||
"""Get a new realm."""
|
||||
resp, body = self.http_client.json_request(
|
||||
RealmsManager.base_url + '/' + realm_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, realm_name, realm):
|
||||
"""Update a realm."""
|
||||
resp, body = self.http_client.json_request(
|
||||
RealmsManager.base_url + '/' + realm_name, 'PUT',
|
||||
body=realm
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, realm_name):
|
||||
"""Delete a realm."""
|
||||
resp, body = self.http_client.request(
|
||||
RealmsManager.base_url + "/" + realm_name,
|
||||
'DELETE',
|
||||
body=''
|
||||
)
|
||||
return body
|
59
surveilclient/v2_0/config/servicegroups.py
Normal file
59
surveilclient/v2_0/config/servicegroups.py
Normal file
@ -0,0 +1,59 @@
|
||||
# Copyright 2014-2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
|
||||
|
||||
class ServiceGroupsManager(surveil_manager.SurveilManager):
|
||||
base_url = '/config/servicegroups'
|
||||
|
||||
def list(self):
|
||||
"""Get a list of servicegroups."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ServiceGroupsManager.base_url, 'GET'
|
||||
)
|
||||
return body
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a new servicegroup."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ServiceGroupsManager.base_url, 'POST',
|
||||
body=kwargs
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, servicegroup_name):
|
||||
"""Get a new servicegroup."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ServiceGroupsManager.base_url + '/' + servicegroup_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, servicegroup_name, servicegroup):
|
||||
"""Update a servicegroup."""
|
||||
resp, body = self.http_client.json_request(
|
||||
ServiceGroupsManager.base_url + '/' + servicegroup_name, 'PUT',
|
||||
body=servicegroup
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, servicegroup_name):
|
||||
"""Delete a servicegroup."""
|
||||
resp, body = self.http_client.request(
|
||||
ServiceGroupsManager.base_url + "/" + servicegroup_name,
|
||||
'DELETE',
|
||||
body=''
|
||||
)
|
||||
return body
|
59
surveilclient/v2_0/config/timeperiods.py
Normal file
59
surveilclient/v2_0/config/timeperiods.py
Normal file
@ -0,0 +1,59 @@
|
||||
# Copyright 2014-2015 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from surveilclient.common import surveil_manager
|
||||
|
||||
|
||||
class TimePeriodsManager(surveil_manager.SurveilManager):
|
||||
base_url = '/config/timeperiods'
|
||||
|
||||
def list(self):
|
||||
"""Get a list of timeperiods."""
|
||||
resp, body = self.http_client.json_request(
|
||||
TimePeriodsManager.base_url, 'GET'
|
||||
)
|
||||
return body
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a new timeperiod."""
|
||||
resp, body = self.http_client.json_request(
|
||||
TimePeriodsManager.base_url, 'POST',
|
||||
body=kwargs
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, timeperiod_name):
|
||||
"""Get a new timeperiod."""
|
||||
resp, body = self.http_client.json_request(
|
||||
TimePeriodsManager.base_url + '/' + timeperiod_name, 'GET',
|
||||
body=''
|
||||
)
|
||||
return body
|
||||
|
||||
def update(self, timeperiod_name, timeperiod):
|
||||
"""Update a timeperiod."""
|
||||
resp, body = self.http_client.json_request(
|
||||
TimePeriodsManager.base_url + '/' + timeperiod_name, 'PUT',
|
||||
body=timeperiod
|
||||
)
|
||||
return body
|
||||
|
||||
def delete(self, timeperiod_name):
|
||||
"""Delete a timeperiod."""
|
||||
resp, body = self.http_client.request(
|
||||
TimePeriodsManager.base_url + "/" + timeperiod_name,
|
||||
'DELETE',
|
||||
body=''
|
||||
)
|
||||
return body
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user