Can I load all entities from a file in one go? - fiware-orion

I have a file with a list of entities in JSON format:
[
{
"id": "IST-AFRICA-2018_Sensor6",
"type": "Device",
"TC": {
"type": "Sensor",
"value": 24.26,
"metadata": {
...
I can I add them all in one go in Orion?
I tried:
curl -v localhost:1026/v2/op/update -s -S --header 'Content-Type: application/json' --header 'Fiware-Service:waziup' -d '{ "actionType": "APPEND", "entities": `cat file.json`}"
But without success.

I found this solution:
jq -c -r '.[]' entities.json | while read i; do
echo "inserting $i"
echo $i | curl -X POST "http://localhost:1026/v2/entities" -s -S --header 'Content-Type:application/json' -d #-
done

Related

PowerShell Delete lines from output

I am running the following command part of a script in powershell, and need to get rid of the return carriages or white lines and brackets.
Original execution and output:
grpcurl -d '{ "service": "service1" }' -H "authorization: key key" service1.env.domain.net:port grpc.health.v1.Health/Check
{
"status": "SERVING"
}
Now I am able to remove the brackets..
Original execution and output:
grpcurl -d '{ "service": "service1" }' -H "authorization: key key" service1.env.domain.net:port grpc.health.v1.Health/Check | Select-String "status"
"status": "SERVING"
Now the question, how can I get this output ??
"status": "SERVING"

IBM Cloud Secrets Manager: Unable to create an arbitrary secret

I am trying the following API request for IBM Cloud Secrets Manager, but it fails:
curl -X POST "https://{instance_ID}.{region}.secrets-manager.appdomain.cloud/api/v1/secrets/arbitrary" -H "Authorization: Bearer $IAM_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" -d '{
"metadata": {
"collection_type": "application/vnd.ibm.secrets-manager.secret+json",
"collection_total": 1
},
"resources": [
{
"name": "example-arbitrary-secret",
"description": "Extended description for my secret.",
"secret_group_id": "432b91f1-ff6d-4b47-9f06-82debc236d90",
"payload: "secret-data",
"expiration_date": "2030-12-31T00:00:00Z",
"labels": [
"dev",
"us-south"
]
}
]
}'
There was a missing double-quote after payload...
curl -X POST "https://{instance_ID}.{region}.secrets-manager.appdomain.cloud/api/v1/secrets/arbitrary" -H "Authorization: Bearer $IAM_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" -d '{
"metadata": {
"collection_type": "application/vnd.ibm.secrets-manager.secret+json",
"collection_total": 1
},
"resources": [
{
"name": "example-arbitrary-secret",
"description": "Extended description for my secret.",
"secret_group_id": "432b91f1-ff6d-4b47-9f06-82debc236d90",
"payload": "secret-data",
"expiration_date": "2030-12-31T00:00:00Z",
"labels": [
"dev",
"us-south"
]
}
]
}'

error while importing curl request in Postman

I am trying to test rest api as mentioned here from Postman. I followed this thread here and tried importing the curl request in Postman but it's failing with the following error:
Here is the complete curl command:
curl \
--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
--header "Content-Type: application/json" \
--request PATCH \
--data '[
{
"operation": "add",
"field": "/members/-",
"value": {"_ref" : "managed/user/scarter"}
}
]' \
"http://localhost:8080/openidm/managed/role/cedadaed-5774-4d65-b4a2-41d455ed524a"
{
"_id": "cedadaed-5774-4d65-b4a2-41d455ed524a",
"_rev": "2",
"name": "employee",
"description": "Role granted to workers on the company payroll"
}

Yahoo Gemini sandbox creation "INVALID_EMAIL_ADDRESS"

Trying to create a sandbox as described here:
https://developer.yahoo.com/gemini/guide/navigate-the-api/testing/
After trying all sorts of different things, I've ended up with the exact request from the docs:
curl -X POST \
http://sandbox-api.gemini.yahoo.com/v2/rest/advertisersignup \
-H 'Authorization: Bearer nZ8hzgmc5...' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 03e2855d-3f5f-4780-a8f5-014f16bf1fac' \
-d '{
"advertiserName": "sandbox test"
}'
But I keep getting an "invalid email" error.
{
"errors": [
{
"errIndex": -1,
"code": "E40000_INVALID_INPUT",
"message": "[INVALID_EMAIL_ADDRESS]",
"description": ""
}
],
"response": {
"advertiserName": "sandbox test"
},
"timestamp": "2018-07-30 22:08:07"
}
Am I missing something?

Doubts about notifications format in Orion usin APIv2

we are testing the subscription functionality using the APIv2. We are following the guidelines described in http://telefonicaid.github.io/fiware-orion/api/v2/ . We are able to create a correct subscription but the format of the notification messages that we received is not what we expected. The format of these messages is like the APIv1 version. Is this the expected behavior?
We are using the Docker image from https://hub.docker.com/r/fiware/orion/.
Version information about the build:
{
"orion" : {
"version" : "1.0.0-next",
"uptime" : "0 d, 1 h, 28 m, 47 s",
"git_hash" : "a729812c45d2749fffbc19add17631b2fffc8797",
"compile_time" : "Fri Apr 8 10:05:55 UTC 2016",
"compiled_by" : "root",
"compiled_in" : "838a42ae8431"
}
}
Steps to reproduce:
Create an entity:
(curl -X POST http://<cb_url>:<cb_port>/v2/entities?options=keyValues -s -S --header 'Content-Type: application/json' \
--header 'Accept: application/json' -d #- | python -mjson.tool) <<EOF
{
"type":"Room",
"id": "test",
"humidity":40
}
EOF
Create a subscription:
(curl -X POST http://<cb_url>:<cb_port>/v2/subscriptions -s -S --header 'Content-Type: application/json' \
--header 'Accept: application/json' -d #- | python -mjson.tool) <<EOF
{
"description": "One subscription to rule them all",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "Room"
}
],
"condition": {
"attributes": [
"humidity"
],
"expression": {
"q": "humidity>40"
}
}
},
"notification": {
"callback": "http://192.168.99.1:5000",
"attributes": [
"humidity"
],
"throttling": 5
},
"expires": "2016-05-05T14:00:00.00Z"
}
EOF
Update attribute.:
(curl -X PUT <cb_url>:<cb_port>/v2/entities/test/attrs/humidity/value -s -S --header 'Content-Type: application/json' \
--header 'Accept: application/json' -d #- | python -mjson.tool) <<EOF
{
"value": 50
}
EOF
We get the notification with the following format:
{u'contextResponses': [
{u'contextElement': {
u'attributes': [{
u'name': u'humidity',
u'type': u'none',
u'value': {u'value': 50}
}],
u'id': u'test',
u'isPattern': u'false',
u'type': u'Room'
},
u'statusCode': {
u'code': u'200',
u'reasonPhrase': u'OK'
}}],
u'originator': u'localhost',
u'subscriptionId': u'5707b72882fc213130f4e5b9'}
NGSIv2 notification formats have not been yet implemented (at Orion 1.0.0). Note that NGSIv2 is yet in beta status and sometimes the specification (where the new notification format has been defined) is a step forward the implementation.
There is a github issue about this, to which you can subscribe in order to know when this feature gets implemented.
EDIT: NGSIv2 notification formats have been implemented in Orion 1.1.0.