Zig
Zig
Bluzone Get Project Details
See more Bluzone Examples
Get a project by its idChilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = try chilkat.Http.init();
defer http.deinit();
// 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.setRequestHeader("bzid", "YOUR_API_KEY_HERE");
const sb_response_body = try chilkat.StringBuilder.init();
defer sb_response_body.deinit();
http.quickGetSb("https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/", sb_response_body) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
const j_resp = try chilkat.JsonObject.init();
defer j_resp.deinit();
j_resp.loadSb(sb_response_body) catch {};
j_resp.setEmitCompact(false);
std.debug.print("Response Body:\n", .{});
std.debug.print("{s}\n", .{try j_resp.emit(alloc)});
const resp_status_code = http.getLastStatus();
std.debug.print("Response Status Code = {d}\n", .{resp_status_code});
if (resp_status_code >= 400) {
std.debug.print("Response Header:\n", .{});
std.debug.print("{s}\n", .{try http.getLastHeader(alloc)});
std.debug.print("Failed.\n", .{});
return;
}
// 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
var i: i32 = 0;
_ = j_resp.intOf("projectId");
_ = try j_resp.stringOf(alloc, "name");
_ = try j_resp.stringOf(alloc, "description");
_ = try j_resp.stringOf(alloc, "status");
_ = try j_resp.stringOf(alloc, "owner.username");
_ = try j_resp.stringOf(alloc, "owner.emailAddress");
_ = try j_resp.stringOf(alloc, "defaultUuidValue");
_ = j_resp.boolOf("enableLocusMaps");
_ = try j_resp.stringOf(alloc, "mapProviderType");
_ = j_resp.boolOf("enableAdvancedPackets");
_ = try j_resp.stringOf(alloc, "enabledPacketTypes");
_ = j_resp.boolOf("enableDataUnload");
_ = j_resp.boolOf("enableScanConsumer");
_ = j_resp.boolOf("enablePolicyConsumer");
_ = j_resp.boolOf("enableLocationConsumer");
_ = j_resp.boolOf("enableEmail");
_ = try j_resp.stringOf(alloc, "firmwareUpdateStrategy");
_ = j_resp.intOf("deviceJobConcurrency");
_ = try j_resp.stringOf(alloc, "mapProviderApiKey");
_ = try j_resp.stringOf(alloc, "wakeupUuid");
_ = try j_resp.stringOf(alloc, "reportTimezone");
_ = try j_resp.stringOf(alloc, "language");
_ = try j_resp.stringOf(alloc, "blufiHostnameNaming");
_ = j_resp.intOf("dateCreated");
_ = j_resp.intOf("dateUpdated");
_ = j_resp.boolOf("enableStreamProducer");
_ = j_resp.boolOf("enableMetricStorage");
i = 0;
const count_i = j_resp.sizeOfArray("reportEmailList");
while (i < count_i) {
j_resp.setI(i);
i = i + 1;
}
}