I want to add a collaboration using the v2 api - but it requires a user id. How do I get the user id if all I have is the login name?
When adding a collaborator, you can send either the user id or the user's email address:
i.e. both
curl https://api.box.com/2.0/collaborations \-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"item": { "id": "FOLDER_ID", "type": "folder"}, "accessible_by": { "id": "USER_ID"}, "role": "editor"}' \
-X POST
and
curl https://api.box.com/2.0/collaborations \-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"item": { "id": "FOLDER_ID", "type": "folder"}, "accessible_by": { "login": "USER_EMAIL"}, "role": "editor"}' \
-X POST
will work. In the case of the second example, the user doesn't have to have a Box account.
http://developers.box.com/docs/#collaborations-add-a-collaboration
Related
Let assume we have an entity corresponding to an IoT controller device, let say a door controller.
We want to define an event that could cause an action (open/close). So we need to send a command to this device.
How would we make this happen? Add an attribute in the entity like for example setDoorStatus that can be written to via the NGSI API? And then have some IoT agent or command handler subscribe to this attribute?
Is there any example of a Data Model where this is done?
The easiest way to do this is to provision a device using any IoT Agent. IoT Agents have a standard API for device provisioning, where commands can be listed:
curl -L -X POST 'http://localhost:4041/iot/devices' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
"devices": [
{
"device_id": "door001",
"entity_name": "urn:ngsi-ld:Door:001",
"entity_type": "Door",
"protocol": "PDI-IoTA-UltraLight",
"transport": "HTTP",
"endpoint": "http://context-provider:3001/iot/door001",
"commands": [
{"name": "unlock","type": "command"},
{"name": "open","type": "command"},
{"name": "close","type": "command"},
{"name": "lock","type": "command"}
],
"attributes": [
{"object_id": "s", "name": "state", "type":"Text"}
],
"static_attributes": [
{"name":"refStore", "type": "Relationship","value": "urn:ngsi-ld:Store:001"}
]
}
]
}
'
The IoT Agent node library defines a command paradigm for actuating devices through commands
In this case you have an attribute open which is registered on a context broker as coming from a device and you can actuate the device using the following request:
NGSI-v2
curl -L -X PATCH 'http://localhost:1026/v2/entities/urn:ngsi-ld:Door:001/attrs' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
"open": {
"type" : "command",
"value" : ""
}
}'
NSGI-LD
curl -L -X PATCH 'http://localhost:4041/ngsi-ld/v1/entities/urn:ngsi-ld:Device:door001/attrs/open' \
-H 'NGSILD-Tenant: openiot' \
-H 'NGSILD-Path: /' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--data-raw '{
"type": "Property",
"value": ""
}'
The relevant IoT Agent accepts the request and passes it down to the device using the appropriate device syntax. Once activated, additional special status and info attributes are added to the entity as soon as it has any information of the command progress.
Full examples can be found within the FIWARE Tutorials:
NGSI-v2
NGSI-LD
When running this list files there is not a nextPageToken there is just files[].
curl \
'https://www.googleapis.com/drive/v3/files?fields=files(id%2C%20name)&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
result:
{
"files": [
{
"id": "1",
"name": "1"
},
...
{
"id": "2",
"name": "2"
}
]
}
Leaving the fields parameter empty, the nextPageToken is returned.
curl \
'https://www.googleapis.com/drive/v3/files?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
result:
{
"kind": "drive#fileList",
"nextPageToken": "~!!~AI9FV7TN...",
"incompleteSearch": false,
"files": [
{
"kind": "drive#file",
"id": "1",
"name": "1",
"mimeType": "application/vnd.google-apps.spreadsheet"
},
...
Is this a bug or is there some way to get the nextPageToken and limit the fields returned? The doc page for fields implies that it should work:
Note: The Drive API supports query parameters for data pagination (maxResults and nextPageToken). For APIs that support these parameters, use these parameters to reduce the results of each query to a manageable size. Otherwise, the performance gains possible with partial response might not be realized.
When fields=files(id,name) is used for the method of "Files: list", the file ID and filename are returned. In this case, the values of fields are files.id and files.name. nextPageToken is not included in fields. By this, the page token is not returned. When fields is not used, it seems that fields of nextPageToken,incompleteSearch,kind,files(id,name,kind,mimeType) is the default value. So I thought that this is not a bug, and it might be the current specification.
So when you want to retrieve nextPageToken when you use https://www.googleapis.com/drive/v3/files?fields=files(id%2C%20name), please include nextPageToken in fields as follows.
Modified curl command:
curl \
'https://www.googleapis.com/drive/v3/files?fields=nextPageToken%2Cfiles%28id%2Cname%29&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
In this case, fields is nextPageToken,files(id,name).
Result:
When above curl command is run, the following result is returned.
{
"nextPageToken": "###",
"files": [
{"id": "###", "name": "###"},
{"id": "###", "name": "###"},
,
,
,
]
}
Reference:
Files: list
I am trying to see how I can patch a Pod for OpenShift Via Rest by following the OpenShift Pod-Patch Rest Documentation. I have been able to post data with other apis from OpenShift such as Secret.
If I do curl call just to update the metadata name of a given pod:
curl -k \
-X PATCH \
-d #- \
-H "Authorization: Bearer $TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json-patch+json' \
$OPENSHIFT_URL/api/v1/namespaces/mytestproject/pods/app-1-build << 'EOF'
{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "app-2-build"
}
}
EOF
I get the response:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "json: cannot unmarshal object into Go value of type jsonpatch.Patch",
"code": 500
}
I am unable to figure out what I am doing incorrect based on the schema, and the documentation at OpenShift for pod does not show examples of the json data schema in curl examples.
I've been trying to use the Post references (https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-references-POST/) to set up the reference between two files in forge but although I get a message "success" as result when I try it on the forge viewer I still see the files separately even after I translate the models. Has someone been through the same issue?
Without seeing you code it is hard to tell what is happening. Below I copied my bash script code which references/translate an obj with material and texture.
Au.obj
+- Au.mtl
+- Au.jpg
After upload, I got these
idObj="urn:adsk.objects:os.object:cyrillejcrja/Au.obj"
idMtl="urn:adsk.objects:os.object:cyrillejcrja/Au.mtl"
idJpg="urn:adsk.objects:os.object:cyrillejcrja/Au.jpg"
the code to set references, now
urn=$(xbase64encode $idObj)
job='{
"urn": "'${idObj}'",
"filename": "Au.obj",
"references": [{
"urn": "'${idMtl}'",
"relativePath": "./Au.mtl",
"filename": "Au.mtl",
"references": [{
"urn": "'${idJpg}'",
"relativePath": "./Au.jpg"
}]
}]
}'
response=$(curl -H "Content-Type: application/json" \
-H "Authorization: ${bearer}" \
-X POST ${ForgeHost}/modelderivative/v2/designdata/${urn}/references \
-k -s -d "${job}")
Here is got a reply like below which only means that the references are registered.
{
"result": "success"
}
Now, I do this to translate the obj and use the references
urn=$(xbase64encode $idObj)
job='{
"input": {
"urn": "'${urn}'",
"checkReferences": true
},
"output": {
"formats": [
{
"type": "svf",
"views": [
"2d",
"3d"
]
}
]
}
}'
response=$(curl -H "Content-Type: application/json" \
-H "Authorization: ${bearer}" \
-H "x-ads-force: true" \
-X POST ${ForgeHost}/modelderivative/v2/designdata/job \
-k -s -d "${job}")
Note the "checkReferences": true, as documented here.
Now, I can wait the translation to complete and see the result in the Viewer.
For reference the xbase64safeencode function used above
function xbase64safeencode () { local id64=$(echo -ne $1 | base64 $wrap_arg | tr -d '=' | tr '+/' '-_'); echo $id64; }
#Cyrille, this is my request:
curl -X 'POST' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsI' -H 'Content-Type: application/json' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/{urn}/references' -d
'{
"urn": "urn:adsk.objects:os.object:bucket/non-existent.rvt",
"filename": "",
"references": [
{
"urn": "urn:adsk.objects:os.object:bucket/non-existent.rvt",
"relativePath": "",
"filename": ""
}
]
}'
I got as result:
'{
"result": "success"
}'
The point is I'm getting success as a result even when I do not have the specified file on the server, so I'd suggest few server-side validations, for example, when a model has been translated once we can't set as reference right so it should at least return an error. Thank you and I hope this helps.
Is it possible to use the Global Instance of Keystone to retrieve registered user profile info?
According to these references: https://github.com/telefonicaid/fiware-pep-steelskin#keystone and Keystone create user and permissions by api, it seems possible if I wish to install an instance by my own. However, what if I wish to use the Global Instance, instead. Is it possible?
For example, I have tested te retrieve some data as indicated below without success:
curl -s -H "X-Auth-Token:cXylpiNyh74V6J9YOlqN2GTzYSmGQa" http://cloud.lab.fiware.org:4730/v2.0/tokens | python -mjson.tool
curl -s -H "X-Auth-Token:cXylpiNyh74V6J9YOlqN2GTzYSmGQa" http://cloud.lab.fiware.org:4730/v3/users/ | python -mjson.tool
curl http://cloud.lab.fiware.org:4730/v3/auth/tokens -H "Content-Type: application/json" -d ' { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "domain": { "name": "matest" }, "name": "pep_proxy_99c59...", "password": "e3025a286dab..." } } } } }'
Note: I have tried both port: 5000 and 4730.
Any hint will be appreciated.
Users doesn't have permissions to see other users information or to create new users using the API.
However, you can issue tokens from the global keystone using both v2.0 and v3 protocols:
curl -X POST http://130.206.84.8:4730/v2.0/tokens \
-H 'Content-Type: application/json' \
-d "{\"auth\": {\"tenantName\": \"${OS_TENANT_NAME}\",
\"passwordCredentials\": {
\"username\": \"$OS_USERNAME\",
\"password\": \"$OS_PASSWORD\"}}}" | \
jq -r '.access.token.id'
Or issue a token in v3:
curl -v -H "Content-Type: application/json" -d "
{ \"auth\": {
\"identity\": {
\"methods\": [\"password\"],
\"password\": {
\"user\": {
\"name\": \"$OS_USERNAME\",
\"domain\": { \"id\": \"default\" },
\"password\": \"$OS_PASSWORD\"
}
}
}
}
}" http://cloud.lab.fiware.org:4730/v3/auth/tokens 2>&1 \
| grep -i "X-Subject-Token"
There are few things you can do with Keystone itself using these tokens if you are not the admin user (Non admin users obviously have few permissions). However, you coud, for instance query the endpoints:
curl -s -H "X-Auth-Token: $TOKEN_ID" http://130.206.84.8:4730/v3/endpoints
The domains:
curl -s -H "X-Auth-Token: $TOKEN_ID" http://130.206.84.8:4730/v3/domains