neris-api-client 1.3.6__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neris_api_client
3
- Version: 1.3.6
3
+ Version: 1.5.0
4
4
  Summary: NERIS API Client
5
5
  Author-email: Ben Coleman <ben.coleman@ul.org>, Tommy Messbauer <thomas.messbauer@ul.org>, Joseph Pagani <joseph.pagani@ul.org>
6
6
  Project-URL: Homepage, https://github.com/ulfsri/neris-api-client
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "neris_api_client"
7
- version = "1.3.6"
7
+ version = "1.5.0"
8
8
  authors = [
9
9
  { name="Ben Coleman", email="ben.coleman@ul.org" },
10
10
  { name="Tommy Messbauer", email="thomas.messbauer@ul.org" },
@@ -2,7 +2,7 @@ import base64
2
2
  from http import HTTPStatus
3
3
  import json
4
4
  from uuid import UUID
5
- from typing import List, Optional, Dict, Any
5
+ from typing import List, Optional, Dict, Any, Literal
6
6
  from datetime import datetime, timedelta
7
7
 
8
8
  import requests
@@ -11,6 +11,10 @@ from pydantic import BaseModel
11
11
  from .config import Config, GrantType, TokenSet
12
12
 
13
13
  from .models import (
14
+ DeptSortBy,
15
+ StatesTerrs,
16
+ SortDirection,
17
+ TypeEntityValue,
14
18
  IncidentPayload,
15
19
  PatchUnitPayload,
16
20
  CreateUnitPayload,
@@ -228,6 +232,37 @@ class NerisApiClient(_NerisApiClient):
228
232
  def get_entity(self, neris_id: str) -> Dict[str, Any]:
229
233
  return self._call("get", f"/entity/{neris_id}")
230
234
 
235
+ def list_entities(
236
+ self,
237
+ name: str | None = None,
238
+ neris_id: str | None = None,
239
+ state: StatesTerrs | None = None,
240
+ entity_subtype: TypeEntityValue | None = None,
241
+ last_modified: str | None = None,
242
+ page_number: int | None = None,
243
+ page_size: int | None = None,
244
+ sort_by: DeptSortBy | None = None,
245
+ sort_direction: SortDirection | None = None,
246
+ ) -> Dict[str, Any]:
247
+ params = dict(
248
+ name=name,
249
+ neris_id=neris_id,
250
+ state=state,
251
+ entity_subtype=entity_subtype,
252
+ last_modified=last_modified,
253
+ page_number=page_number,
254
+ page_size=page_size,
255
+ sort_by=sort_by,
256
+ sort_direction=sort_direction,
257
+ )
258
+
259
+ # delete null params
260
+ for k in list(params.keys()):
261
+ if params[k] is None:
262
+ del params[k]
263
+
264
+ return self._call("get", "/entity", params=params)
265
+
231
266
  def create_entity(self, body: str | Dict[str, Any]) -> Dict[str, Any]:
232
267
  return self._call("post", "/entity/", body, model=CreateDepartmentPayload)
233
268
 
@@ -283,6 +318,46 @@ class NerisApiClient(_NerisApiClient):
283
318
  "post", f"/incident/{neris_id}/validate", data=body, model=IncidentPayload
284
319
  )
285
320
 
321
+ def list_incidents(
322
+ self,
323
+ *,
324
+ neris_id_entity: str | None = None,
325
+ incident_types: list[str] | None = None,
326
+ incident_types_set_operation: Literal["UNION", "INTERSECTION"] | None = None,
327
+ call_create_start: datetime | None = None,
328
+ call_create_end: datetime | None = None,
329
+ incident_number: str | None = None,
330
+ dispatch_incident_number: str | None = None,
331
+ status: list[Literal["APPROVED", "PENDING_APPROVAL", "REJECTED", "SUBMITTED"]] | None = None,
332
+ last_modified: str | None = None,
333
+ sort_by: Literal["call_create", "neris_id_entity", "incident_number", "dispatch_incident_number", "status", "last_modified"] | None = None,
334
+ sort_direction: Literal["ASCENDING", "DESCENDING"] | None = None,
335
+ page_size: int | None = None,
336
+ cursor: str | None = None,
337
+ ) -> dict[str, Any]:
338
+ params = dict(
339
+ neris_id_entity=neris_id_entity,
340
+ incident_types=incident_types,
341
+ incident_types_set_operation=incident_types_set_operation,
342
+ call_create_start=call_create_start and call_create_start.isoformat(),
343
+ call_create_end=call_create_end and call_create_end.isoformat(),
344
+ incident_number=incident_number,
345
+ dispatch_incident_number=dispatch_incident_number,
346
+ status=status,
347
+ last_modified=last_modified,
348
+ sort_by=sort_by,
349
+ sort_direction=sort_direction,
350
+ page_size=page_size,
351
+ cursor=cursor,
352
+ )
353
+
354
+ # delete null params
355
+ for k in list(params.keys()):
356
+ if params[k] is None:
357
+ del params[k]
358
+
359
+ return self._call("get", "/incident", params=params)
360
+
286
361
  def patch_entity(self, neris_id: str, body: str | Dict[str, Any]) -> Dict[str, Any]:
287
362
  return self._call("patch", f"/entity/{neris_id}", data=body, model=PatchDepartmentPayload)
288
363