Skip to main content

Python wrapper for GuardPoint 10 Access Control System

Project description

pyGuardPoint

pyGuardPoint is a Python wrapper for the GuardPoint 10 API, which allows developers to easily integrate with the GuardPoint 10 physical access control system (ACS).

pyGuardPoint aims to provide a pythonic OOP style programming interface to the WebAPI of GuardPoint 10 (GP10), perfect for quickly building proof-of-concepts. GuardPoint 10 controls and monitors doors,lifts,readers etc. pyGuardPoint currently focuses more on the management of Cardholders over the monitoring and setup of the physical infrastructure.

At the time of writing the current version of GuardPoint 10 is Version 1.90.3. Learn more about the GuardPoint 10 ACS here https://www.sensoraccess.co.uk/guardpoint10/

pyGuardPoint is not compatible with the legacy ACS GuardPoint Pro.

What is it good for?

Rapid development of applications and scripts using the GuardPoint ACS. pyGuardPoint manages your authenticated connection to GuardPoint 10, so there is know need to construct complex OData URLs. The Python object Cardholder represents a user/person on the system. Modify your Cardholder's attributes and update them with just a couple of lines of code.

Examples

Firstly you will always need to import the module:

from pyGuardPoint import GuardPoint, Cardholder, Card

It is recommended to use a mutually authenticated secure connection to the GuardPoint server in production environments.

To establish a secure connection with a PKCS#12(*.p12) credential file:

gp = GuardPoint(host="https://sensoraccess.duckdns.org", pwd="admin",
                    p12_file="MobileGuardDefault.p12",
                    p12_pwd="test")

To retrieve a list of cardholders:

gp = GuardPoint(host="10.0.0.1", pwd="password")
cardholders = gp.get_card_holders(search_terms="Jeff Buckley")
for cardholder in cardholders:
    print(cardholder.lastName)

To create a new cardholder:

gp = GuardPoint(host="10.0.0.1", pwd="password")
cardholder_pd = CardholderPersonalDetail(email="jeff.buckley@test.com")
cardholder = Cardholder(firstName="Jeff", lastName="Buckley",
                        cardholderPersonalDetail=cardholder_pd)
cardholder = gp.new_card_holder(cardholder)

To create a card for the cardholder - A card can represent an assortment of Identity tokens(magnetic-card, smartcard, QRCode , vehicle number plate etc) - as long as it contains a unique card-code:

from pyGuardPoint import GuardPoint, Card

gp = GuardPoint(host="sensoraccess.duckdns.org", pwd="password")

cardholders = gp.get_card_holders(firstName="Jeff", lastName="Buckley")
if len(cardholders) < 1:
    exit()

card = Card(cardType="Magnetic", cardCode="1A1B1123")
cardholders[0].cards.append(card)
if gp.update_card_holder(cardholders[0]):
    updated_cardholder = gp.get_card_holder(uid=cardholders[0].uid)
    print(f"Cardholder {updated_cardholder.firstName} {updated_cardholder.lastName} Updated")
    print(f"\tEmail: {updated_cardholder.cardholderPersonalDetail.email}")
    print(f"\tCards: {updated_cardholder.cards}")

The get_card_holders method can be used with a whole host of flags for filtering:

cardholders = gp.get_card_holders(search_terms="Frank Smith Countermac",
                                      cardholder_type_name='Visitor',
                                      filter_expired=True,
                                      select_ignore_list=['cardholderCustomizedField',
                                                          'cardholderPersonalDetail',
                                                          'securityGroup',
                                                          'cards',
                                                          'photo'],
                                      select_include_list=['uid', 'lastName', 'firstName', 'lastPassDate',
                                                           'insideArea', 'fromDateTime'],
                                      sort_algorithm=SortAlgorithm.FUZZY_MATCH,
                                      threshold=10)

The class Cardholder has a couple of convenience functions:

cardholder.dict(non_empty_only=True)) # Convert to python dictionary
cardholder.pretty_print()   # Print nicely in the terminal window

To get a list of areas/zones, and count the number of cardholders in each:

gp = GuardPoint(host="sensoraccess.duckdns.org", pwd="password")

areas = gp.get_areas()

areas = gp.get_areas()
for area in areas:
    cardholder_count = gp.get_card_holders(count=True, areas=area)
    print(f"Cardholders in {area.name} = {str(cardholder_count)}")

To get a list of security groups:

sec_groups = gp.get_security_groups()
for sec_group in sec_groups:
    print(sec_group)

Scheduling the membership of an Access Group to a Cardholder:

# Get a cardholder
cardholder = gp.get_card_holder(card_code='1B1A1B1C')

# Add and associate schedule access group to cardholder
fromDateValid = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
toDateValid = (datetime.now() + timedelta(hours=1)).strftime('%Y-%m-%dT%H:%M:%SZ')
sm = ScheduledMag(scheduledSecurityGroupUID=sec_groups[0].uid,
                  cardholderUID=cardholder.uid,
                  fromDateValid=fromDateValid,
                  toDateValid=toDateValid)
gp.add_scheduled_mag(sm)

scheduled_mags = gp.get_scheduled_mags()
for scheduled_mag in scheduled_mags:
    print(scheduled_mag)

More

The code and further examples can be found at https://github.com/SensorAccess/pyGuardPoint

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pyGuardPoint-0.9.7.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyGuardPoint-0.9.7-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file pyGuardPoint-0.9.7.tar.gz.

File metadata

  • Download URL: pyGuardPoint-0.9.7.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for pyGuardPoint-0.9.7.tar.gz
Algorithm Hash digest
SHA256 dc7073d60b2051274482c83f4a128dd108bbe204cd643eeed92960f700bd1f1e
MD5 6b4d1f6359bf08e74e6bd32f3488f1d0
BLAKE2b-256 1ae8bf3082a3ee705ee3c8a8ff7833d88a961f595fc0eaf14aa62437d9e83dde

See more details on using hashes here.

File details

Details for the file pyGuardPoint-0.9.7-py3-none-any.whl.

File metadata

  • Download URL: pyGuardPoint-0.9.7-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for pyGuardPoint-0.9.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f7e43a606df49a0f7d5acd06d01aad1fe18da5a9c785a5a4b8f45966a7a78ce9
MD5 04c0b129b2b8aef2b87ed1e7b446e629
BLAKE2b-256 81d8c9ca2946e9ebc77c969f5cc04b4d969e15e5c85b7e20ca7cb0f8d7333e4e

See more details on using hashes here.

Supported by

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