Lua
Lua
Bluzone Get Project Details
See more Bluzone Examples
Get a project by its idChilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
-- Implements the following CURL command:
-- curl -X GET \
-- https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/ \
-- -H 'bzid: YOUR_API_KEY_HERE'
http:set_request_header("bzid", "YOUR_API_KEY_HERE")
local sbResponseBody = chilkat.StringBuilder.new()
local success = http:quick_get_sb("https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/", sbResponseBody)
if not success then
print(http.last_error_text)
return
end
local jResp = chilkat.JsonObject.new()
jResp:load_sb(sbResponseBody)
jResp.emit_compact = false
print("Response Body:")
print(jResp:emit())
local respStatusCode = http.last_status
print("Response Status Code = " .. respStatusCode)
if respStatusCode >= 400 then
print("Response Header:")
print(http.last_header)
print("Failed.")
return
end
-- Sample JSON response:
-- {
-- "projectId": 36845,
-- "name": "My Project",
-- "description": "Default Project for admin@chilkatsoft.com, created on Thu Jun 06 17:18:11 GMT 2019.",
-- "status": null,
-- "owner": {
-- "username": "admin@chilkatsoft.com",
-- "emailAddress": null
-- },
-- "defaultUuidValue": "1b4b243c-59aa-405f-90b5-0c434cac1345",
-- "enableLocusMaps": false,
-- "mapProviderType": "GOOGLE",
-- "enableAdvancedPackets": false,
-- "enabledPacketTypes": "sBv2",
-- "enableDataUnload": false,
-- "enableScanConsumer": false,
-- "enablePolicyConsumer": false,
-- "enableLocationConsumer": false,
-- "enableEmail": true,
-- "firmwareUpdateStrategy": "MANUAL",
-- "deviceJobConcurrency": -1,
-- "mapProviderApiKey": null,
-- "wakeupUuid": null,
-- "reportEmailList": [
-- ],
-- "reportTimezone": "Etc/GMT",
-- "language": "en",
-- "blufiHostnameNaming": "DEFAULT",
-- "dateCreated": 1559841491000,
-- "dateUpdated": 1559841491000,
-- "enableStreamProducer": true,
-- "enableMetricStorage": true
-- }
-- Sample code for parsing the JSON response...
-- Use the following online tool to generate parsing code from sample JSON:
-- Generate Parsing Code from JSON
local projectId = jResp:int_of("projectId")
local name = jResp:string_of("name")
local description = jResp:string_of("description")
local status = jResp:string_of("status")
local ownerUsername = jResp:string_of("owner.username")
local ownerEmailAddress = jResp:string_of("owner.emailAddress")
local defaultUuidValue = jResp:string_of("defaultUuidValue")
local enableLocusMaps = jResp:bool_of("enableLocusMaps")
local mapProviderType = jResp:string_of("mapProviderType")
local enableAdvancedPackets = jResp:bool_of("enableAdvancedPackets")
local enabledPacketTypes = jResp:string_of("enabledPacketTypes")
local enableDataUnload = jResp:bool_of("enableDataUnload")
local enableScanConsumer = jResp:bool_of("enableScanConsumer")
local enablePolicyConsumer = jResp:bool_of("enablePolicyConsumer")
local enableLocationConsumer = jResp:bool_of("enableLocationConsumer")
local enableEmail = jResp:bool_of("enableEmail")
local firmwareUpdateStrategy = jResp:string_of("firmwareUpdateStrategy")
local deviceJobConcurrency = jResp:int_of("deviceJobConcurrency")
local mapProviderApiKey = jResp:string_of("mapProviderApiKey")
local wakeupUuid = jResp:string_of("wakeupUuid")
local reportTimezone = jResp:string_of("reportTimezone")
local language = jResp:string_of("language")
local blufiHostnameNaming = jResp:string_of("blufiHostnameNaming")
local dateCreated = jResp:int_of("dateCreated")
local dateUpdated = jResp:int_of("dateUpdated")
local enableStreamProducer = jResp:bool_of("enableStreamProducer")
local enableMetricStorage = jResp:bool_of("enableMetricStorage")
local i = 0
local count_i = jResp:size_of_array("reportEmailList")
while i < count_i do
jResp.i = i
i = i + 1
end