-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathhunt_groups.py
More file actions
108 lines (83 loc) · 3.61 KB
/
hunt_groups.py
File metadata and controls
108 lines (83 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""Webex Features: Hunt Group API wrapper.
Copyright (c) 2016-2024 Cisco and/or its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
from ..restsession import RestSession
from ..utils import (
check_type,
dict_from_items_with_values,
)
API_ENDPOINT = "features/huntGroups"
OBJECT_TYPE = "hunt_group"
class HuntGroupsAPI(object):
"""Webex Features: Hunt Group API.
Wraps the Webex Calling Hunt Group API and exposes the API as native
Python methods that return native Python objects.
See: https://developer.webex.com/docs/api/v1/features-hunt-group
"""
def __init__(self, session, object_factory):
"""Initialize a new HuntGroupsAPI object with the provided RestSession.
Args:
session(RestSession): The RESTful session object to be used for
API calls to the Webex service.
object_factory(callable): The factory function to use to create
Python objects from the returned Webex JSON data objects.
Raises:
TypeError: If the parameter types are incorrect.
"""
check_type(session, RestSession)
super(HuntGroupsAPI, self).__init__()
self._session = session
self._object_factory = object_factory
def create(
self,
org_id,
location_id,
name,
extension,
**request_parameters,
):
"""Create a hunt group.
Creates a new hunt group for the given organization and location.
See: https://developer.webex.com/docs/api/v1/features-hunt-group/
create-a-hunt-group
Args:
org_id(str): The ID of the organization.
location_id(str): The ID of the location for the hunt group.
name(str): A user-friendly name for the hunt group.
extension(str): The extension for the hunt group.
**request_parameters: Additional request body parameters (e.g.
phoneNumber, callRoutingPattern, agents, etc.).
Returns:
ImmutableData: The created hunt group object.
Raises:
TypeError: If the parameter types are incorrect.
ApiError: If the Webex cloud returns an error.
"""
check_type(org_id, str)
check_type(location_id, str)
check_type(name, str)
check_type(extension, str)
post_data = dict_from_items_with_values(
request_parameters,
orgId=org_id,
locationId=location_id,
name=name,
extension=extension,
)
json_data = self._session.post(API_ENDPOINT, json=post_data)
return self._object_factory(OBJECT_TYPE, json_data)