Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a paradigm for implementing search endpoints for the SDK and CLI #51

Open
1 of 25 tasks
devraj opened this issue Jul 4, 2024 · 0 comments
Open
1 of 25 tasks
Assignees
Labels
enhancement New feature or request

Comments

@devraj
Copy link
Member

devraj commented Jul 4, 2024

Is your feature request related to a problem? Please describe.
Search is a common feature around the API and has two main characteristics:

Describe the solution you'd like
Provide a standardised way to implement search among all the endpoints that support it. In particular we want to:

  • Reduce the amount of endpoint specific code and do as much in the core endpoint
  • Ability to provide metadata to the CLI or other user facing interfaces to draw from

I suggest implementing an end to end solution for two of the endpoints to prove the use case and the requirements e.g:

  • Card types
  • Cardholders

Consider leaving attribute filtering out of the initial solution to keep things relatively simple.

Describe alternatives you've considered
NA

Additional context
There are certain parameters like name that support sql like syntax:

Limits the returned items to those with a name that matches this string.
Without surrounding quotes or a percent sign or underscore, it is a substring
match; surround the parameter with double quotes "..." for an exact match.
Without quotes, a percent sign % will match any substring and an underscore
will match any single character.

We should ensure that those parameters are sanitised before they are sent through to the REST API.

Checklist of the various endpoints that support search, for implementation reference:

  • Cardholders
  • Card types
  • Competencies
  • Access groups
  • Operator groups
  • PDF definitions
  • Receptions
  • Redactions
  • Roles
  • Visits
  • Events
  • Items
  • Access Zones
  • Alarm Zones
  • Day categories
  • Doors
  • Elevator groups
  • Fence zones
  • Inputs
  • Interlock groups
  • Macros
  • Outputs
  • Schedules

Sample interaction with httpie:

(gallagher-py3.11) ➜  gallagher git:(alpha-5) ✗ task debug:get -- "card_types/?name=mobile"
task: [debug:get] http get \
https://commandcentre-api-au.security.gallagher.cloud/api/'card_types/?name=mobile' \
"Authorization: GGL-API-KEY $GACC_API_KEY"

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 406
Content-Type: application/json; charset=utf-8
Date: Thu, 04 Jul 2024 12:31:04 GMT

{
    "results": [
        {
            "availableCardStates": [
                "Active",
                "Disabled (manually)",
                "Lost",
                "Stolen",
                "Damaged"
            ],
            "credentialClass": "mobile",
            "defaultExpiry": {
                "expiryType": "none"
            },
            "facilityCode": "P61405",
            "href": "https://commandcentre-api-au.security.gallagher.cloud/api/card_types/9640",
            "id": "9640",
            "initialCardState": "Active",
            "issueLevel": 1,
            "name": "Mobile Credential",
            "sendRegistrationEmail": true,
            "sendRegistrationSms": true
        }
    ]
}
@devraj devraj added the enhancement New feature or request label Jul 4, 2024
@devraj devraj added this to the alpha-finalisation milestone Jul 4, 2024
@devraj devraj self-assigned this Jul 4, 2024
devraj added a commit that referenced this issue Jul 5, 2024
implements a version of search in the core package for all endpoints to
use, this performs a number of cleanups:

- removes unused search method signatures and merges them into core
- updates enum with a generic signature that can be reused
- updates test case for testing cardholder profiles
- cleans up core to accept parameters as part of the internal get call

refs #51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant