Closed gormless87 closed 1 year ago
Need to connect with Team Alliance on their Forest Client API
thinking this could be further broken down into two tickets
Got some information from Maria (Team Alliance) today:
Q: how to request access through API Services Portal for Forest Client Api if it is available?
It may not be available next week. Reply from Alliance Team:
Hi Ian,
Thanks for the reply! We'll try to make it published within the next sprint, hopefully within the next 3 weeks. I'll keep you posted. Also I'll add your one search endpoint request to our backlogs.
Thanks, Catherine
On 2023-01-05, 4:07 PM, "Liu, Ian" <po-yi.liu@cgi.com mailto:po-yi.liu@cgi.com> wrote:
Thanks for getting back on this. If there is just one search endpoint (with text parameter either on clientName or clientNumber) that would be ideal, but I think this is sufficient. Would you let me know when this api will be published to the Endpoint Service Portal next week?
Thank you. -Ian
Team Alliance is planning to publish the Forest Client API by next week Friday (Jan 20th) at which point we can request for access through the API services portal. In the interim, we can begin working on the FAM backend for the forest client API.
Forest client api specification: test: https://nr-forest-client-api-test.api.gov.bc.ca/ prod: https://nr-forest-client-api-prod.api.gov.bc.ca/
Forest Client API access requested (status: waiting for token):
Will need to first find out (with sample client and sample results), when secure token is approved:
/api/clients/findAllNonIndividuals
) clients and do internal filtering based on FAM frontend search criteria, initial caching, and how about performance in this case?
@basilv Got "TEST" environment API Key: 4r0dn5wC0JTs6N1tdw6NDzpjBRQwEJ6u Using Postman and try:
https://nr-forest-client-api-test.api.gov.bc.ca/api/clients/findByClientNumber/00001011
result:
{"clientNumber":"00001011","clientName":"AKIECA EXPLORERS LTD.","clientStatusCode":"ACT","clientTypeCode":"C","acronyms":[]}
https://nr-forest-client-api-test.api.gov.bc.ca/api/clients/findByNames?page=1&size=10&clientName=AKIECA EXPLORERS LTD.&clientTypeCode=C
result: Getting no result back, strange. It is the clientName
and clientTypeCode
got back from first request to use in this request.Probably an issue with the spaces in the URL. I'm pretty sure spaces aren't allowed (get mapped to %20).
Good catch but I tried, still having no luck...
Did you try a different forest client with no spaces in the name?
https://nr-forest-client-api-test.api.gov.bc.ca/api/clients/findByClientNumber/00000020
=> {"clientNumber":"00000020","clientName":"DAINACK","legalFirstName":"HONORINE","legalMiddleName":"Margaret","clientStatusCode":"DAC","clientTypeCode":"I","acronyms":[]}
https://nr-forest-client-api-test.api.gov.bc.ca/api/clients/findByNames?page=1&size=10&clientName=DAINACK&clientTypeCodes=I
=> []
empty... "Note": param is "clientTypeCodes" not "clientTypeCode" based on api spec.
I wasn't aware the page
parameter needs to be starting at "0", not "1" (normally I thought it should be 1 the first page).
Can also ignore page
parameter.
https://nr-forest-client-api-test.api.gov.bc.ca/api/clients/findByNames?page=0&clientName=AKIECA EXPLORERS LTD.
or
https://nr-forest-client-api-test.api.gov.bc.ca/api/clients/findByNames?clientName=AKIECA EXPLORERS LTD.
Both works:
[
{
"clientNumber": "00001011",
"clientName": "AKIECA EXPLORERS LTD.",
"clientStatusCode": "ACT",
"clientTypeCode": "C",
"acronyms": []
}
]
As tested it out locally from frontend to backend (locally - implementation in progress), this is json structure returned from backend to browser console: This should be a good starting for frontend.
Request URL: http://localhost:8000/forest_clients/search?client_number=00001011
[{"client_name":"AKIECA EXPLORERS LTD.","forest_client_number":"00001011","status":{"status_code":"A","description":"Active"}}]
Moving comment below from nr-fom/280 "These are the client status from "Forest Client API":
ACT (Active) DAC (Deactivated) DEC (Deceased) REC (Receivership) SPN (Suspended) FAM backend will return to FAM frontend with mapping of client status codes (from Forest Client API) with: "Active (Active)" and "Inactive (Inactive) - Deactivated, Deceased, Receivership, Suspended". For the "backend" validation before saving user-role assignment, I assume only the "exists forest client with Active status" can be granted for access. However, curious if current "bulk users role assignment imported from the script include all other client status other than Active" and will this "Active" status restriction affects the script import. #481 Won't check "client type" before saving, since all types are valid including "individuals", see comment from #179. @basilv @ianliuwk1019 These are the client status from "Forest Client API":
ACT (Active) DAC (Deactivated) DEC (Deceased) REC (Receivership) SPN (Suspended) FAM backend will return to FAM frontend with mapping of client status codes (from Forest Client API) with: "Active (Active)" and "Inactive (Inactive) - Deactivated, Deceased, Receivership, Suspended". For the "backend" validation before saving user-role assignment, I assume only the "exists forest client with Active status" can be granted for access. However, curious if current "bulk users role assignment imported from the script include all other client status other than Active" and will this "Active" status restriction affects the script import. #481 Won't check "client type" before saving, since all types are valid including "individuals", see comment from #179. @basilv @ArogeG "
As we are now able to query Forest Client API and get back attributes, and in this ticket we are doing forest_client_number validation in the backend, "clientName" is also available in backend for saving into database (but need to add new column into fam_forest_client table). However, for reducing the scope of this ticket and no immediate use of the "clientName" field, as discussed in the scrum, we will not at this ticket saving "clientName" into FAM table.
PROD API Token is requested and approved. The api token setup is configured for our FAM all environments and currently is in PR. Note! - Current PROD Forest Client API isn't accessible; contacted Forest Client API Team last week and is currently being investigated.
Got reply back from Maria that Forest Client API Prod is working now.
Sorry @ArogeG , as disussed, we can wait for Nick's frontend work #179 so we can deploy both backend and frontend together for this feature as a whole set. Currently if only deploy backend, it will not work from frontend side. Thanks.
Since code review is done on this, and it is merged to main and presumably deployed to dev, I think this should be moved to review/QA. Gbola could in theory test via OpenAPI page, or wait for front-end work to finish.
@ArogeG if you like to test it from swagger/OpenAPI page, please let me know and I can help with that.
As a an application access administrator I want to see a list of forest client So That I can select a forest client for an assignment.
Additional Context -- Integrate Forest Client API with frontend and back-end for validation. --Allow users to select and search for a forest client by forest organization name/client and ID. --If Forest Client does not exists, return a message "Forest Client cannot be Found". --Security - must be logged FAM user in order for FC API to work
Acceptance Criteria
From the front end, can execute a search and get results returned from the Forest Client API
Definition of Done Ready to Demo in Sprint Review Does what I have made have appropriate test coverage? Documentation and/or scientific documentation exists and can be found Peer Reviewed by 2 people on the team Manual testing of all PRs in Dev and Prod Merged
Cloned from #179