open-insight/LSL2/STPROC/LABELING_API.txt
Infineon\Ouellette 9651c48539 Initial addition for Test Wafer Tracking Phase 2
Includes services and functions to create new
test wafer lot. Tables included outside of git push
New Tables:
1. LOT
2. LOT_EVENT
3. LOT_OPERATION
4. PRODUCT_OPERATION
5. OPERATION
6. Added PRODUCT_OPERATIONS field in TEST_WAFER_PROD table.
All relational indexes and btree indexes.
2024-10-24 20:23:15 +02:00

108 lines
5.2 KiB
Plaintext

Function Labeling_API(@API)
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from SRP Computer Solutions, Inc.
Name : Labeling_API
Description : API logic for the Labeling resource.
Notes : All web APIs should include the API_SETUP insert. This will provide several useful variables:
HTTPMethod - The HTTP Method (Verb) submitted by the client (e.g., GET, POST, etc.)
APIURL - The URL for the API entry point (e.g., api.mysite.com/v1).
FullEndpointURL - The URL submitted by the client, including query params.
FullEndpointURLNoQuery - The URL submitted by the client, excluding query params.
EndpointSegment - The URL endpoint segment.
ParentURL - The URL path preceeding the current endpoint.
CurrentAPI - The name of this stored procedure.
Parameters :
API [in] -- Web API to process. Format is [APIPattern].[HTTPMethod]:
- APIPattern must follow this structure Labeling[.ID.[<Property>]]
- HTTPMethod can be any valid HTTP method, e.g., GET, POST, PUT, DELETE, etc.
Examples:
- Labeling.POST
- Labeling.ID.PUT
- Labeling.ID.firstName.GET
Response [out] -- Response to be sent back to the Controller (HTTP_MCP) or requesting procedure. Web API
services do not rely upon anything being returned in the response. This is what the
various services like SetResponseBody and SetResponseStatus services are for. A response
value is only helpful if the developers want to use it for debug purposes.
History : (Date, Initials, Notes)
10/22/24 xxx Original programmer.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
Declare function Labeling_Services, OI_Wizard_Services
$insert APP_INSERTS
$insert API_SETUP
$insert HTTP_INSERTS
GoToAPI else
// The specific resource endpoint doesn't have a API handler yet.
HTTP_Services('SetResponseStatus', 204, 'This is a valid endpoint but a web API handler has not yet been created.')
end
Return Response OR ''
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Endpoint Handlers
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
API labeling.HEAD
API labeling.GET
OIWizardID = ''
Cookies = HTTP_Services('GetHTTPCookie')
For each Cookie in Cookies using ';'
Key = Field(Cookie, '=', 1)
If Key EQ 'sessionID' then
OIWizardID = Field(Cookie, '=', 2)
end
Next Cookie
ValidSession = OI_Wizard_Services('ValidateSession', OIWizardID)
If ValidSession then
//Send back list of printers
PrinterList = Labeling_Services('GetAllZebraPrinters')
If SRP_JSON(hJSONCollection, 'New', 'Object') then
hPrinterArray = ''
If SRP_JSON(hPrinterArray, 'New', 'Array') then
for each ZebraPrinter in PrinterList using @FM setting printerPos
//Create individual printer object
hPrinterObj = ''
If SRP_Json(hPrinterObj, 'New', 'Object') then
SRP_JSON(hPrinterObj, 'SetValue', 'PrinterId', ZebraPrinter<1,1>)
SRP_JSON(hPrinterObj, 'SetValue', 'PrinterIPAddress', ZebraPrinter<1,2>)
SRP_JSON(hPrinterObj, 'SetValue', 'PrinterPort', ZebraPrinter<1,3>)
SRP_JSON(hPrinterArray, 'Add', hPrinterObj)
SRP_JSON(hPrinterObj, 'Release')
end
Next ZebraPrinter
SRP_JSON(hJSONCollection, 'Set', 'ZebraPrinters', hPrinterArray)
SRP_JSON(hPrinterArray, 'Release')
end
JSONCollection = SRP_JSON(hJSONCollection, 'Stringify', 'Styled')
SRP_JSON(hJSONCollection, 'Release')
end
If Error_Services('NoError') then
HTTP_Services('SetResponseStatus', 201, 'Success')
HTTP_Services('SetResponseHeaderField', 'Content-Location', FullEndpointURL)
HTTP_Services('SetResponseBody', JSONCollection, False$, 'application/hal+json')
end else
HTTP_Services('SetResponseStatus', 400, Error_Services('GetMessage'))
end
end else
HTTP_Services('SetResponseStatus', 401, 'Invalid session. Reauthentication required.')
end
end api