Skip to content

Instantly share code, notes, and snippets.

@lsloan
Created June 27, 2016 16:36
Show Gist options
  • Save lsloan/b60ae73b61a15f4a1cf474f20f59cb7a to your computer and use it in GitHub Desktop.
Save lsloan/b60ae73b61a15f4a1cf474f20f59cb7a to your computer and use it in GitHub Desktop.
Post a rudimentary Caliper event to an endpoint. Assumes USER and HOSTNAME environment variables are available.
#!/bin/sh --
NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # ISO 8601 format, UTC
CURL_STDIN='@-' # cURL's notation for stdin
curl "https://endpoint.example.org/caliper" \
--request POST \
--header "Content-Type: application/json" \
--capath /etc/pki/tls/certs/ \
--data ${CURL_STDIN} << EOT
{
"sensor":"${USER}_curl",
"sendTime":"${NOW}",
"data":[
{
"@context":"http://purl.imsglobal.org/ctx/caliper/v1/Context",
"@type":"http://purl.imsglobal.org/caliper/v1/SessionEvent",
"actor":{
"@id":"https://${HOSTNAME}/person/${USER}",
"@context":"http://purl.imsglobal.org/ctx/caliper/v1/Context",
"@type":"http://purl.imsglobal.org/caliper/v1/lis/Person"
},
"eventTime":"${NOW}",
"action":"http://purl.imsglobal.org/vocab/caliper/v1/action#LoggedIn"
}
]
}
EOT
@lsloan
Copy link
Author

lsloan commented Jun 27, 2016

@arwhyte, @pushyamig: This is great for testing connectivity to an endpoint. OAuth support will be added later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment