Metadata-Version: 2.1
Name: acslib
Version: 0.1.7
Summary: A library for interacting with Access Control Systems like Genetec or Ccure9k
Author-email: Jeremy Gibson <jmgibso3@ncsu.edu>, Luc Sanchez <lgsanche@ncsu.edu>, Ryan Semmler <rsemmle@ncsu.edu>
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: pydantic>=2.5.3, <3.0.0
Requires-Dist: sat-utils>=1.1.12, <2.0.0
Requires-Dist: pytest>=6.2.5, <7.0.0 ; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0, <5.0.0 ; extra == "dev"
Requires-Dist: pytest-mock>=3.10.0, <4.0.0 ; extra == "dev"
Requires-Dist: coverage[toml]>=6.2 ; extra == "dev"
Requires-Dist: black>=23.3.0, <24.0.0 ; extra == "dev"
Requires-Dist: ruff==0.1.1 ; extra == "dev"
Requires-Dist: mkdocs-material>=9.4.6, <10.0.0 ; extra == "dev"
Requires-Dist: pymdown-extensions>=10.3.1, <11.0.0 ; extra == "dev"
Requires-Dist: mkdocs-include-markdown-plugin>=6.0.3, <7.0.0 ; extra == "dev"
Requires-Dist: mkdocstrings>=0.23.0, <1.0.0 ; extra == "dev"
Requires-Dist: mkdocstrings-python>=1.7.3, <2.0.0 ; extra == "dev"
Requires-Dist: Pygments>=2.10.0, <3.0.0 ; extra == "dev"
Requires-Dist: bandit>=1.7.4, <2.0.0 ; extra == "dev"
Requires-Dist: bandit[toml]>=1.7.4, <2.0.0 ; extra == "dev"
Requires-Dist: pre-commit>=2.16.0, <3.0.0 ; extra == "dev"
Requires-Dist: isort>=5.10.1, <6.0.0 ; extra == "dev"
Requires-Dist: pyupgrade>=2.29.1, <3.0.0 ; extra == "dev"
Requires-Dist: flit>=3.8.0, <4.0.0 ; extra == "dev"
Requires-Dist: Faker>=20.0.0, <21.0.0 ; extra == "dev"
Project-URL: Homepage, https://github.ncsu.edu/SAT/acslib
Provides-Extra: dev

# Access Control Systems Library

A library for interacting with Access Control Systems like Genetec or Ccure9k. This is a work in progress and is not ready for production use.

Currently development is heavily influenced by Ccure9k, but the goal is to abstract the differences between the two systems and provide a common
interface for interacting with them.

* Free software: MIT
* Documentation: <https://github.com/ncstate-sat/acslib>

## Features

* Currently supports Search for `Personnel`, `Clearances`, `Credentials`, and `ClearanceItem` in Ccure9k
* Supports search by custom fields.

## Usage

### Personnel

#### Find a person by name

```python
from acslib import CcureAPI

ccure_api = CcureAPI()
response = ccure_api.personnel.search("Roddy Piper".split())
```

#### Find a person by custom field

```python
from acslib import CcureAPI
from acslib.ccure.filters import PersonnelFilter, FUZZ

ccure_api = CcureAPI()
search_filter = PersonnelFilter(lookups={"Text1": FUZZ})
response = ccure_api.personnel.search(["PER0892347"], search_filter=search_filter)
```

#### Update a personnel record

```python
from acslib import CcureAPI

# change MiddleName and Text14 for the person with CCure ID 5001
ccure_api = CcureAPI()
ccure_api.personnel.update(5001, {"Text14": "new text here", "MiddleName": "Shaquille"})
```

#### Add new personnel record

```python
from acslib import CcureAPI
from acslib.ccure.types import PersonnelCreateData as pcd

ccure_api = CcureAPI()
new_person_data = pcd(FirstName="Kenny", LastName="Smith", Text1="001132808")
ccure_api.personnel.create(new_person_data)
```

#### Delete a personnel record

```python
from acslib import CcureAPI

# delete the personnel record with the CCure ID 6008
ccure_api = CcureAPI()
ccure_api.personnel.delete(6008)
```

### Clearance

#### Find a Clearance by name

```python
from acslib import CcureAPI

ccure_api = CcureAPI()
response = ccure_api.clearance.search(["suite", "door"])
```

#### Find a Clearance by other field

```python
from acslib import CcureAPI
from acslib.ccure.filters import ClearanceFilter, NFUZZ

# search by ObjectID
ccure_api = CcureAPI()
search_filter = ClearanceFilter(lookups={"ObjectID": NFUZZ})
response = ccure_api.clearance.search([8897], search_filter=search_filter)
```

### Credential

#### Find all credentials

```python
from acslib import CcureAPI

ccure_api = CcureAPI()
response = ccure_api.credential.search()
```

#### Find a credential by name

```python
from acslib import CcureAPI

# fuzzy search by name
ccure_api = CcureAPI()
response = ccure_api.credential.search(["charles", "barkley"])
```

#### Find a credential by other field

```python
from acslib import CcureAPI
from acslib.ccure.filters import CredentialFilter, NFUZZ

# search by ObjectID
ccure_api = CcureAPI()
search_filter = CredentialFilter(lookups={"ObjectID": NFUZZ})
response = ccure_api.credential.search([5001], search_filter=search_filter)
```

#### Update a credential

```python
from acslib import CcureAPI

# update CardInt1 for the credential with ObjectID 5001
ccure_api = CcureAPI()
response = ccure_api.credential.update(5001, {"CardInt1": 12345})
```

### ClearanceItem

Clearance items include "door" and "elevator."

#### Find ClearanceItem by name

```python
from acslib import CcureAPI
from acslib.ccure.types import ClearanceItemType as cit

# fuzzy search for doors by name
ccure_api = CcureAPI()
response = ccure_api.clearance_item.search(cit.DOOR, ["hall", "interior"])
```

#### Find ClearanceItem by other field

```python
from acslib import CcureAPI
from acslib.ccure.filters import ClearanceItemFilter, NFUZZ
from acslib.ccure.types import ClearanceItemType as cit

# search elevators by ObjectID
ccure_api = CcureAPI()
search_filter = ClearanceItemFilter(lookups={"ObjectID": NFUZZ})
response = ccure_api.clearance_item.search(cit.ELEVATOR, [5000], search_filter=search_filter)
```

#### Update ClearanceItem

```python
from acslib import CcureAPI
from acslib.ccure.types import ClearanceItemType as cit
# change a door's name
ccure_api = CcureAPI()
response = ccure_api.clearance_item.update(cit.DOOR, 5000, update_data={"Name": "new door name 123"})
```

#### Create ClearanceItem

```python
from acslib import CcureAPI
from acslib.ccure.types import ClearanceItemCreateData, ClearanceItemType as cit

# create a new elevator
ccure_api = CcureAPI()
new_elevator_data = ClearanceItemCreateData(
    Name="New elevator 1",
    Description="newest elevator in town",
    ParentID=5000,
    ParentType="SoftwareHouse.NextGen.Common.SecurityObjects.iStarController",
    ControllerID=5000,
    ControllerClassType="SoftwareHouse.NextGen.Common.SecurityObjects.iStarController"
)
response = ccure_api.clearance_item.create(cit.ELEVATOR, create_data=new_elevator_data)
```

#### Delete ClearanceItem

```python
from acslib import CcureAPI
from acslib.ccure.types import ClearanceItemType as cit
# delete a door
ccure_api = CcureAPI()
response = ccure_api.clearance_item.delete(cit.DOOR, 5000)
```

