OnGuard/lenel API to create Event Alarm for Door forced - access-control

I am working on Lnl_IncomingEvent.
Curl request
curl --request POST \
--url 'https://HOST:PORT/api/access/onguard/openaccess/execute_method?version=1.0'
--header 'Application-Id: APP_ID'
--header 'Content-Type: application/json'
--header 'Session-Token: TOKEN'
--cookie OASessionID= SESSIONID
--data '{ "type_name": "Lnl_IncomingEvent", "property_value_map": { "Category": 0, "Description": "Door Held Open", "ID": 43, "SubtypeID": 10, "SupportParameters": 0, "TypeID": 4 }, "method_name": "SendIncomingEvent", "in_parameter_value_map": { "Device":"DEVICE", "SubDevice": "SUBDEVICE", "Description": "Test event create", "Source": "logicalSource" }
}'
I am passing and expecting it to create Door Held Open
"property_value_map": {
"Category": 0,
"Description": "Door Held Open",
"ID": 43,
"SubtypeID": 10,
"SupportParameters": 0,
"TypeID": 4
},
This creates a "Generic Type Event" which I can check in the log
{
"alarm_ack_blue_channel": 128,
"alarm_ack_green_channel": 255,
"alarm_ack_red_channel": 255,
"alarm_blue_channel": 128,
"alarm_green_channel": 255,
"alarm_priority": 150,
"alarm_red_channel": 255,
"asset_id": 0,
"badge_id": 0,
"badge_id_str": "0",
"badge_issue_code": -1,
"cardholder_key": 0,
"controller_id": 4,
"controller_name": "logicalSource",
"description": "Generic Event",
"device_id": 1,
"device_name": "DEVICE",
"event_source_name": "",
"event_subtype": 0,
"event_text": "Test event create",
"event_type": 30,
"must_acknowledge": false,
"must_mark_in_progress": false,
"serial_number": 169797,
"subdevice_id": 1,
"timestamp": "2022-07-07T14:36:37-07:00"
}
As you can see "description": "Generic Event".
Question:
How can I create Door Held Open event?

Related

Retrieving Custom Question/Responses on Booking/Event

Is there any way to get an EXPORT of all Scheduled, Past and Upcoming Events from my Account BUT via a webhook or API? 
Specifically, I want to be able to also get the Responses to questions on these bookings/events. 
I can get the List of events okay using an API HOWEVER this does not pass back the responses to the questions on the event.  Is there any way to do this programmatically?
If I was able to make a call to trigger the EXPORT function as available through the interface of my account, that would be great and meet the requirements of the data I need.
Thank you
The answers to questions are specific to each Invitee, not the whole Event (an Event can have multiple Invitees), so you need to get List of Invitees (in API v2) for a given Event. Each Invitee item will have a questions_and_answers array.
Example request and response:
curl --request GET \
--url https://api.calendly.com/scheduled_events/<UUID>/invitees \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json'
{
"collection": [
{
"cancel_url": "https://calendly.com/cancellations/AAAAAAAAAAAAAAAA",
"created_at": "2020-11-23T17:51:18.327602Z",
"email": "test#example.com",
"event": "https://api.calendly.com/scheduled_events/AAAAAAAAAAAAAAAA",
"name": "John Doe",
"new_invitee": null,
"old_invitee": null,
"questions_and_answers": [
{
"answer": "radio button answer",
"position": 0,
"question": "Question with Radio Buttons answer type"
},
{
"answer": "Multiple line\nAnswer",
"position": 1,
"question": "Question with Multiple Lines answer type"
},
{
"answer": "Answer 1\nAnswer 2\nAnswer 3",
"position": 2,
"question": "Question with Checkboxes answer type"
}
],
"reschedule_url": "https://calendly.com/reschedulings/AAAAAAAAAAAAAAAA",
"rescheduled": false,
"status": "active",
"text_reminder_number": null,
"timezone": "America/New_York",
"tracking": {
"utm_campaign": null,
"utm_source": null,
"utm_medium": null,
"utm_content": null,
"utm_term": null,
"salesforce_uuid": null
},
"updated_at": "2020-11-23T17:51:18.341657Z",
"uri": "https://api.calendly.com/scheduled_events/AAAAAAAAAAAAAAAA/invitees/AAAAAAAAAAAAAAAA",
"canceled": false,
"payment": {
"external_id": "ch_AAAAAAAAAAAAAAAAAAAAAAAA",
"provider": "stripe",
"amount": 1234.56,
"currency": "USD",
"terms": "sample terms of payment (up to 1,024 characters)",
"successful": true
}
}
],
"pagination": {
"count": 1,
"next_page": "https://calendly.com/scheduled_events/AAAAAAAAAAAAAAAA/invitees?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
}
}
Note: if you have an Event URI from a previous API response (e.g. https://api.calendly.com/scheduled_events/846428db-f54e-4196-8075-4204673aac7a), just append /invitees to it to get a list of all Invitees. You don't have to build the whole URL from scratch.

How to get Execution details through API Calls in Rundeck

I am trying to create a dashboard, for which i am getting all the details using API in Rundeck
and then want to write the data in Csv File,
here is an example trying to fetch data for weekly basis, which is not working [ error msg: {"error":true,"apiversion":35,"errorCode":"api.error.invalid.request","message":"Invalid API Request: /api/35/executions/1w"}],kindly let me know what am i doing wrong to fetch details on weekly, monthly and daily basis
format
#!/bin/sh
protocol="http"
rdeck_host="machinexyz.local"
rdeck_port="4440"
rdeck_api="35"
rdeck_token="token"
rdeck_project="projectRun"
xy="1w"
curl -s --location --request GET "$protocol://$rdeck_host:$rdeck_port/api/$rdeck_api/project/$rdeck_project/$xy" \
--header "Accept: application/json" \
--header "X-Rundeck-Auth-Token: $rdeck_token
Thanks
Following the documentation you could use the recentFilter parameter on your API call, I did an example (at the end I added the jq command to "beautify" the default output):
#!/bin/sh
# protocol
protocol="http"
# basic rundeck info
rdeck_host="localhost"
rdeck_port="4440"
rdeck_api="36"
rdeck_token="ni28E9M5s5H0s3kyCKQ0tbfPCI8jNZS1"
# specific api call info
rdeck_project="ProjectEXAMPLE"
time="1h"
# api call
curl -s --location --request GET "$protocol://$rdeck_host:$rdeck_port/api/$rdeck_api/project/$rdeck_project/executions?recentFilter=$time" \
--header "Accept: application/json" \
--header "X-Rundeck-Auth-Token: $rdeck_token" \
--header "Content-Type: application/json" | jq
Output:
{
"paging": {
"count": 2,
"total": 2,
"offset": 0,
"max": 20
},
"executions": [
{
"id": 2,
"href": "http://localhost:4440/api/36/execution/2",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/execution/show/2",
"status": "succeeded",
"project": "ProjectEXAMPLE",
"executionType": "scheduled",
"user": "admin",
"date-started": {
"unixtime": 1608296400032,
"date": "2020-12-18T13:00:00Z"
},
"date-ended": {
"unixtime": 1608296400374,
"date": "2020-12-18T13:00:00Z"
},
"job": {
"id": "f2a837d2-1a9c-4387-89d7-0243bbfe6ba9",
"averageDuration": 590,
"name": "HelloWorld",
"group": "",
"project": "ProjectEXAMPLE",
"description": "",
"href": "http://localhost:4440/api/36/job/f2a837d2-1a9c-4387-89d7-0243bbfe6ba9",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/job/show/f2a837d2-1a9c-4387-89d7-0243bbfe6ba9"
},
"description": "echo \"hi\"",
"argstring": null,
"serverUUID": "94ac86b1-56e9-4bc3-9a4c-50cd7c8a5b59",
"successfulNodes": [
"localhost"
]
},
{
"id": 1,
"href": "http://localhost:4440/api/36/execution/1",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/execution/show/1",
"status": "succeeded",
"project": "ProjectEXAMPLE",
"executionType": "scheduled",
"user": "admin",
"date-started": {
"unixtime": 1608295800075,
"date": "2020-12-18T12:50:00Z"
},
"date-ended": {
"unixtime": 1608295800914,
"date": "2020-12-18T12:50:00Z"
},
"job": {
"id": "f2a837d2-1a9c-4387-89d7-0243bbfe6ba9",
"averageDuration": 590,
"name": "HelloWorld",
"group": "",
"project": "ProjectEXAMPLE",
"description": "",
"href": "http://localhost:4440/api/36/job/f2a837d2-1a9c-4387-89d7-0243bbfe6ba9",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/job/show/f2a837d2-1a9c-4387-89d7-0243bbfe6ba9"
},
"description": "echo \"hi\"",
"argstring": null,
"serverUUID": "94ac86b1-56e9-4bc3-9a4c-50cd7c8a5b59",
"successfulNodes": [
"localhost"
]
}
]
}

Pocket API JSON parsing

I am trying to parse the JSON from the Pocket API to keep up with my bookmarks. The JSON recieved after a curl request looks like this:
"list": {
"1548784635": {
"item_id": "1548784635",
"resolved_id": "1548784635",
"given_url": "https://stackoverflow.com/questions/28164849/using-jq-to-par
se-and-display-multiple-fields-in-a-json-serially",
"given_title": "Using jq to parse and display multiple fields in a json se
rially - Stack Ov",
"favorite": "0",
"status": "0",
"time_added": "1542244328",
"time_updated": "1542244341",
"time_read": "0",
"time_favorited": "0",
"sort_id": 0,
"resolved_title": "Using jq to parse and display multiple fields in a json
serially",
"resolved_url": "https://stackoverflow.com/questions/28164849/using-jq-to-
parse-and-display-multiple-fields-in-a-json-serially",
"excerpt": "Using jq I'd like to display first and last name serially. Lik
e so - You can use addition to concatenate strings.",
"is_article": "1",
"is_index": "0",
"has_video": "0",
"has_image": "1",
"word_count": "313",
"lang": "en",
"top_image_url": "https://cdn.sstatic.net/Sites/stackoverflow/img/apple-to
uch-icon#2.png?v=73d79a89bded",
"tags": {
"fields": {
"item_id": "1548784635",
"tag": "fields"
},
"jq": {
"item_id": "1548784635",
"tag": "jq"
},
"multiple": {
"item_id": "1548784635",
"tag": "multiple"
}
},
"authors": {
"45850780": {
"item_id": "1548784635",
"author_id": "45850780",
"name": "abraham",
"url": "https://stackoverflow.com/users/26406/abraham"
},
"82251593": {
"item_id": "1548784635",
"author_id": "82251593",
"name": "San",
"url": "https://stackoverflow.com/users/3713971/san"
}
},
"image": {
"item_id": "1548784635",
"src": "https://i.stack.imgur.com/rZUli.jpg?s=32&g=1",
"width": "32",
"height": "32"
},
"images": {
"1": {
"item_id": "1548784635",
"image_id": "1",
"src": "https://i.stack.imgur.com/rZUli.jpg?s=32&g=1",
"width": "32",
"height": "32",
"credit": "",
"caption": ""
}
},
"domain_metadata": {
"name": "Stack Overflow",
"logo": "https://logo.clearbit.com/stackoverflow.com?size=800",
"greyscale_logo": "https://logo.clearbit.com/stackoverflow.com?size=800&
greyscale=true"
},
"listen_duration_estimate": 121
},
...
I am trying to get the output to look like this with the uri over the tags (trying to transform to csv):
https://stackoverflow.com/questions/28164849/using-jq-to-parse-and-display-multiple-fields-in-a-json-serially
fields, jq, multiple
I tried this but the tags are nested (the consumer_key & access_token are redacted):
curl https://getpocket.com/v3/get --insecure -X POST -H "Content-Type: application/json" -H "X-Accept: application/json" -d "{\"consumer_key\":\"*\", \"access_token\":\"*\", \"detailType\":\"complete\"}" | jq '.list[] | "\(.given_url) \(.tags)"'
Using your sample input after rectification to make it valid JSON:
jq -r '.list[] | [.given_url] + (.tags|keys_unsorted) | #csv' input.json
yields:
"https://stackoverflow.com/questions/28164849/using-jq-to-parse-and-display-multiple-fields-in-a-json-serially","fields","jq","multiple"
This is valid CSV. If you don't want all the double quotation marks, you can use string interpolation as in your attempt.
I added a ?. This works (even for entries without tags). The access_token and consumer_key are redacted in the curl command.
NOTE: the consumer_key & the access_token have each been replace with *
curl https://getpocket.com/v3/get --insecure -X POST -H "Content-Type: application/json" -H "X-Accept: application/json" -d "{\"consumer_key\":\"80793-861ab2c92e846c8324b417e8\", \"access_token\":\"b6b55049-fe0a-df88-8f78-eb9ccc\", \"detailType\":\"complete\"}" | jq -r '.list[] | [.given_url] + (.tags|keys_unsorted?) | #csv' | less
From the jq manual:
.[]?
Like .[], but no errors will be output if . is not an array or object.

Why does /4.0/events/ return NotFoundError in the SocialTables API?

I create several new events in my account. But when I call this endpoint - https://api.socialtables.com/4.0/events/ - I always receive a 404 response with this body:
{
"code": "NotFoundError",
"message": ""
}
If I call the legacy endpoint - https://api.socialtables.com/4.0/legacyvm3/teams/[TEAM-ID]/events - it returns both the legacy events and the new events. But it only tells me the legacy ID values. I guess that's okay, but it's confusing. It looks like I am unable to use the v4 API at all.
Follow-up from this question: Why am I getting 401 UnauthorizedError when getting a list of events using the SocialTables API?
I see it now. Don't use a trailing slash when requesting the /events route:
https://api.socialtables.com/4.0/events
Hmmm not exactly sure where the disconnect is. I just ran that endpoint with your most recent oauth token and got the following result:
[
{
"permissions": [
"CHANGE_OWNER",
"ADD_PLANNER",
"REMOVE_PLANNER",
"ADD_VIEWER",
"REMOVE_VIEWER",
"ADD_CHECKIN",
"REMOVE_CHECKIN",
"UPDATE_EVENT",
"DELETE_EVENT",
"UPDATE_GUEST",
"DELETE_GUEST",
"CREATE_GUEST",
"CHECKIN_GUEST",
"CAN_VIEW"
],
"data": {
"id": "19fdb5e0-1874-11e7-a3a0-65cadad84d84",
"name": "Test Event 5",
"type": "Athletic Event",
"description": null,
"start_epoch": 1492660800000,
"end_epoch": 1492660800000,
"archived": 0,
"deleted": 0,
"status": "ACTIVE",
"has_time": 1,
"timezone": null,
"legacy_id": 1962925,
"industry": "Corporate",
"role": "owner"
}
},
{
"permissions": [
"CHANGE_OWNER",
"ADD_PLANNER",
"REMOVE_PLANNER",
"ADD_VIEWER",
"REMOVE_VIEWER",
"ADD_CHECKIN",
"REMOVE_CHECKIN",
"UPDATE_EVENT",
"DELETE_EVENT",
"UPDATE_GUEST",
"DELETE_GUEST",
"CREATE_GUEST",
"CHECKIN_GUEST",
"CAN_VIEW"
],
"data": {
"id": "e77c8e50-1703-11e7-a3a0-65cadad84d84",
"name": "test event v4",
"type": "Ceremony",
"description": null,
"start_epoch": null,
"end_epoch": null,
"archived": 0,
"deleted": 0,
"status": "ACTIVE",
"has_time": 0,
"timezone": null,
"legacy_id": 1962858,
"industry": "Education",
"role": "owner"
}
}
]
Here's a curl of what I did minus your real token.
curl --request GET \
--url https://api.socialtables.com/4.0/events \
--header 'authorization: Bearer XXXXXXXXXXXXXXXXXXXXXX7063f'
How are you retrieving your token?

Restify very simple JSONClient returns empty json

I just started using restify and tries to build a very simple JSONClient and fails on the first step.
var restify = require('restify');
var client = restify.createJsonClient({
url: 'http://api.bgm.tv'
});
client.get('/calendar', function(err, req, res, obj) {
console.log('%j', obj);
});
This pieces of code returns {} with a status code 200
If you check http://api.bgm.tv/calendar in browser or curl it seems to be a legit json GET Rest API and does not require auth or anything else.
I tried other API such as stackoverflow api it works perfectly, so I assume something wrong with the server side?
If anyone can try to run it and help me point out what might went wrong would be very appreciated.
I runned your example node code and got a proper response (the same you get when browsing).
You probably have some version problem or a console.log size limitation.
Try using: console.log(obj[0]); it should print only the first object in the json.
I'm using node v0.8.9 and restify v2.4.1 on a mac.
Yeah, when I use the Postman plugin for Chrome and do a GET request to http://api.bgm.tv/calendar I get:
[
{
"weekday": {
"en": "Mon",
"cn": "星期一",
"ja": "月耀日",
"id": 1
},
"items": [
{
"id": 46458,
"url": "http://bgm.tv/subject/46458",
"type": 0,
"name": "アイカツ! -アイドルカツドウ!-",
"name_cn": "偶像活动",
"summary": "",
"eps": 0,
"air_date": "2012-10-08",
"air_weekday": 1,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/db/7f/46458_8mM39.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/db/7f/46458_8mM39.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/db/7f/46458_8mM39.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/db/7f/46458_8mM39.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/db/7f/46458_8mM39.jpg"
},
"collection": {
"wish": 0,
"collect": 0,
"doing": 44,
"on_hold": 0,
"dropped": 0
}
},
{
"id": 57150,
"url": "http://bgm.tv/subject/57150",
"type": 0,
"name": "LINE OFFLINE ~サラリーマン~",
"name_cn": "离线LINE - 上班族 -",
"summary": "",
"eps": 0,
"air_date": "2013-01-07",
"air_weekday": 1,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/71/28/57150_Kz171.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/71/28/57150_Kz171.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/71/28/57150_Kz171.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/71/28/57150_Kz171.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/71/28/57150_Kz171.jpg"
},
"collection": {
"wish": 0,
"collect": 0,
"doing": 206,
"on_hold": 0,
"dropped": 0
}
},
{
"id": 58709,
"url": "http://bgm.tv/subject/58709",
"type": 0,
"name": "ハヤテのごとく! Cuties",
"name_cn": "旋风管家 Cuties",
"summary": "",
"eps": 0,
"air_date": "2013-04-08",
"air_weekday": 1,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/15/28/58709_H7uj8.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/15/28/58709_H7uj8.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/15/28/58709_H7uj8.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/15/28/58709_H7uj8.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/15/28/58709_H7uj8.jpg"
},
"collection": {
"wish": 0,
"collect": 0,
"doing": 219,
"on_hold": 0,
"dropped": 0
}
},
...and a bunch more, but the body limit to answers on SO is 30,000 characters.