Skip to main content

A library for interacting with Access Control Systems like Genetec or Ccure9k

Project description

Access Control Systems Library

Release Status

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.

Features

  • Currently supports CRUD operations for Personnel, Clearances, Credentials, and ClearanceItem in Ccure9k, and all other Ccure object types.
  • Supports search by custom fields.

Usage

Personnel

Find a person by name

from acslib import CcureAPI

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

Find a person by custom field

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

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

Update a personnel record

from acslib import CcureAPI

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

Add new personnel record

from acslib import CcureAPI
from acslib.ccure.data_models import PersonnelCreateData as pcd

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

Delete a personnel record

from acslib import CcureAPI

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

Clearance

Find a Clearance by name

from acslib import CcureAPI

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

Find a Clearance by other field

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

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

Credential

Find all credentials

from acslib import CcureAPI

ccure = CcureAPI()
response = ccure.credential.search()

Find a credential by name

from acslib import CcureAPI

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

Find a credential by other field

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

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

Update a credential

from acslib import CcureAPI

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

ClearanceItem

Clearance items include "door" and "elevator."

Find ClearanceItem by name

from acslib import CcureAPI
from acslib.ccure.types import ObjectType

# fuzzy search for doors by name
ccure = CcureAPI()
response = ccure.clearance_item.search(ObjectType.DOOR.complete, ["hall", "interior"])

Find ClearanceItem by other field

from acslib import CcureAPI
from acslib.ccure.filters import ClearanceItemFilter, NFUZZ
from acslib.ccure.types import ObjectType

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

Update ClearanceItem

from acslib import CcureAPI
from acslib.ccure.types import ObjectType
# change a door's name
ccure = CcureAPI()
response = ccure.clearance_item.update(ObjectType.DOOR.complete, 5000, update_data={"Name": "new door name 123"})

Create ClearanceItem

from acslib import CcureAPI
from acslib.ccure.data_models import ClearanceItemCreateData
from acslib.ccure.types import ObjectType

# create a new elevator
ccure = 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.clearance_item.create(ObjectType.ELEVATOR.complete, create_data=new_elevator_data)

Delete ClearanceItem

from acslib import CcureAPI
from acslib.ccure.types import ObjectType

# delete a door
ccure = CcureAPI()
response = ccure.clearance_item.delete(ObjectType.DOOR.complete, 5000)

Other item types

Search for CCure item

from acslib import CcureAPI
from acslib.ccure.filters import CcureFilter, NFUZZ

# search for schedule objects by ObjectID
ccure = CcureAPI()
schedule_type_full = "SoftwareHouse.CrossFire.Common.Objects.TimeSpec"
search_filter = CcureFilter()
response = ccure.ccure_object.search(
    object_type=schedule_type_full,
    search_filter=search_filter,
    terms=[5001]
)

Other common actions

Use ccure.action to perform some common tasks like assigning or revoking clearances or getting personnel images.

Assign a clearance

from acslib import CcureAPI

# assign clearances 5002 and 5003 to person 5005
ccure = CcureAPI()
response = ccure.action.personnel.assign_clearances(
    personnel_id=5005,
    clearance_ids=[5002, 5003],
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acslib-0.1.10.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

acslib-0.1.10-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file acslib-0.1.10.tar.gz.

File metadata

  • Download URL: acslib-0.1.10.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for acslib-0.1.10.tar.gz
Algorithm Hash digest
SHA256 7ec2016518f992c9435f0fba1fad4645f9a7e6b3a24cb675edad4b61f41ad458
MD5 2877841501eca24f2b9d5a4e08b73f4e
BLAKE2b-256 eb6742328de741beb50a23597523cc9e40b08cbd83d1968dc9a8029775e61190

See more details on using hashes here.

File details

Details for the file acslib-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: acslib-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for acslib-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 e291d914a147a3988bec6deea48f8620bd896fa3d44b12c7b01455a7bcb3e9af
MD5 8cd7adb489170d1d3163e83a1c9564b3
BLAKE2b-256 d4e300a7d81f8d4f39d04a1d74555a312e38d814f5a34c5007210b1a8f9c31ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page