Skip to content

Commit 2e3afc2

Browse files
committed
Add endpoints within models
1 parent a016509 commit 2e3afc2

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

pyixapi/models.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ class Connection(Record):
2525
def __str__(self) -> str:
2626
return f"{self.id}: {self.name}"
2727

28+
def cancellation_policy(self) -> dict[str, Any]:
29+
return self._make_request("cancellation-policy")._make_call()
30+
31+
def get_loa(self) -> dict[str, Any]:
32+
return self._make_request("loa")._make_call()
33+
34+
def upload_loa(self, data: dict[str, Any]) -> dict[str, Any]:
35+
return self._make_request("loa")._make_call(verb="post", data=data)
36+
37+
def statistics(self, **kwargs: Any) -> dict[str, Any]:
38+
return self._make_request("statistics")._make_call(add_params=kwargs or None)
39+
40+
def statistics_timeseries(self, aggregate: str, **kwargs: Any) -> dict[str, Any]:
41+
return self._make_request(f"statistics/{aggregate}/timeseries")._make_call(add_params=kwargs or None)
42+
2843

2944
class Contact(Record):
3045
"""
@@ -134,6 +149,21 @@ class NetworkServiceConfig(Record):
134149
def __str__(self) -> str:
135150
return self.id
136151

152+
def cancellation_policy(self) -> dict[str, Any]:
153+
return self._make_request("cancellation-policy")._make_call()
154+
155+
def peer_statistics(self, **kwargs: Any) -> dict[str, Any]:
156+
return self._make_request("peer-statistics")._make_call(add_params=kwargs or None)
157+
158+
def peer_statistics_timeseries(self, aggregate: str, **kwargs: Any) -> dict[str, Any]:
159+
return self._make_request(f"peer-statistics/{aggregate}/timeseries")._make_call(add_params=kwargs or None)
160+
161+
def statistics(self, **kwargs: Any) -> dict[str, Any]:
162+
return self._make_request("statistics")._make_call(add_params=kwargs or None)
163+
164+
def statistics_timeseries(self, aggregate: str, **kwargs: Any) -> dict[str, Any]:
165+
return self._make_request(f"statistics/{aggregate}/timeseries")._make_call(add_params=kwargs or None)
166+
137167

138168
class NetworkService(Record):
139169
"""
@@ -144,6 +174,27 @@ class NetworkService(Record):
144174
def __str__(self) -> str:
145175
return self.id
146176

177+
def cancellation_policy(self) -> dict[str, Any]:
178+
return self._make_request("cancellation-policy")._make_call()
179+
180+
def change_request(self) -> dict[str, Any]:
181+
return self._make_request("change-request")._make_call()
182+
183+
def create_change_request(self, data: dict[str, Any]) -> dict[str, Any]:
184+
return self._make_request("change-request")._make_call(verb="post", data=data)
185+
186+
def delete_change_request(self) -> bool:
187+
return self._make_request("change-request")._make_call(verb="delete")
188+
189+
def rtt_statistics(self, **kwargs: Any) -> dict[str, Any]:
190+
return self._make_request("rtt-statistics")._make_call(add_params=kwargs or None)
191+
192+
def statistics(self, **kwargs: Any) -> dict[str, Any]:
193+
return self._make_request("statistics")._make_call(add_params=kwargs or None)
194+
195+
def statistics_timeseries(self, aggregate: str, **kwargs: Any) -> dict[str, Any]:
196+
return self._make_request(f"statistics/{aggregate}/timeseries")._make_call(add_params=kwargs or None)
197+
147198

148199
class PoP(Record):
149200
"""
@@ -222,6 +273,12 @@ class Port(Record):
222273
def __str__(self) -> str:
223274
return self.name
224275

276+
def statistics(self, **kwargs: Any) -> dict[str, Any]:
277+
return self._make_request("statistics")._make_call(add_params=kwargs or None)
278+
279+
def statistics_timeseries(self, aggregate: str, **kwargs: Any) -> dict[str, Any]:
280+
return self._make_request(f"statistics/{aggregate}/timeseries")._make_call(add_params=kwargs or None)
281+
225282

226283
class PortReservation(Record):
227284
"""
@@ -236,6 +293,15 @@ class PortReservation(Record):
236293
def __str__(self) -> str:
237294
return self.id
238295

296+
def cancellation_policy(self) -> dict[str, Any]:
297+
return self._make_request("cancellation-policy")._make_call()
298+
299+
def get_loa(self) -> dict[str, Any]:
300+
return self._make_request("loa")._make_call()
301+
302+
def upload_loa(self, data: dict[str, Any]) -> dict[str, Any]:
303+
return self._make_request("loa")._make_call(verb="post", data=data)
304+
239305

240306
class RoutingFunction(Record):
241307
"""

0 commit comments

Comments
 (0)