How to set a data-property on a node-connector in draw.io using CSV import-utility? - csv-import

Thanks to the examples supplied by draw.io, I can set all kinds of styled and labelled connectors between my all of my nodes in a diagram. What I haven’t been able to achieve is set a Data-property on a connector.
I can set property “type” to a shape by adding a column “type”.to my CSV-data.
I can set a property "type" on a connector through the user interface in draw.io (Edit Data...)
But I can’t set a data-property “type” to a connector through the CSV-import feature.
I have tried in my CSV configuration a Data-property with a JSON-object.
#connect: { \
# "from": "relatedTo", \
# "to": "id", \
# "fromlabel": "relationLabel", \
# "Data":{"type":"edge"}, \
# "style": "endArrow=%cardinality%;edgeStyle=entityRelationEdgeStyle;curved=1;" \
#}
I have tried adding a key-value-pair.
#connect: { \
# "from": "relatedTo", \
# "to": "id", \
# "fromlabel": "relationLabel", \
# "type":"edge", \
# "style": "endArrow=%cardinality%;edgeStyle=entityRelationEdgeStyle;curved=1;" \
#}
Does anyone know how to add data-properties to a connector in the CSV-import feature of draw.io? There is no example of it in their folder on https://github.com/jgraph/drawio-diagrams/tree/dev/examples/csv

Related

I can't disable the user with the Keyrock API

I want to disable or enable the user found in keyrock with API, but I can't. https://keyrock.docs.apiary.io/ doesn't say how to do it here. Isn't that possible?enter image description here
Log in as an admin user via the REST API.
curl -iX POST \
'http://localhost:3005/v1/auth/tokens' \
-H 'Content-Type: application/json' \
-d '{
"name": "admin#test.com",
"password": "1234"
}'
The response header returns an X-Subject-token Header which identifies who has logged on the application. This token is required in all subsequent requests to gain access.
The image you give in the question is just a GUI version of the GET /users endpoint
curl -L -X GET 'http://localhost:3005/v1/users' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
Or you can request a specific user:
curl -L -X GET 'http://localhost:3005/v1/users/bbbbbbbb-good-0000-0000-000000000000' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
Returns:
{
"user": {
"scope": [],
"id": "bbbbbbbb-good-0000-0000-000000000000",
"username": "bob",
"email": "bob-the-manager#test.com",
"enabled": true,
"admin": false,
"image": "default",
"gravatar": false,
"date_password": "2018-07-30T11:41:14.000Z",
"description": "Bob is the regional manager",
"website": null
}
}
You want to set enabled: false using the PATCH /user endpoint.
curl -L -X PATCH 'http://localhost:3005/v1/users/bbbbbbbb-good-0000-0000-000000000000' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' \
--data-raw '{
"user": {
"username": "bob",
"email": "bob-the-manager#test.com",
"enabled": false,
"gravatar": false,
"date_password": "2018-07-26T15:25:14.000Z"
}
}'
More information can be found within the Security Chapter Tutorials
within the FIWARE documentation where Keyrock is a component found within the FIWARE Catalogue
In the FIWARE documentation an example is given using Keyrock to provide user identities around a "powered by FIWARE" solution. Note that whilst Keyrock is commonly used in "powered by FIWARE" solutions (along with other elements from the FIWARE Catalogue), it could also be used to provide identities for other independent applications or micro-services - it is not tightly bound to only be used in FIWARE scenarios. Similarly alternative open-source or proprietary components for security or identity management systems could be used to secure "powered by FIWARE" solution as well.

Icinga2 API - get specific hosts from templates

How can i set my filters to get only the hosts from a template, which have a custom variable set to true?
With this curl, im getting all hosts in the template but not the ones, which have set the custom_var true
curl -k -s -u $apiuser:$apipassword -H 'Accept: application/json' -X
POST -H 'X-HTTP-Method-Override: GET' https://$url:$port/v1/objects
/hosts -d '{ "filter": "\"template\" in host.templates",
"filter_vars": { "custom_var": true } } ' | jq '.'
Any ideas on how can i get the specific hosts?
Finally got i working. I edited my filter as follows:
-d '{ "filter": "\"template\" in host.templates && host.vars.custom == true" } ''' | jq '.'

passing args to container through docker API

I want to create and start a docker container with some arguments (to the CMD) through docker API using a json file.
curl -XPOST --unix-socket /var/run/docker.sock -d #minio.json -H 'Content-Type: application/json' http://localhost/containers/create?name=minio
curl -XPOST --unix-socket /var/run/docker.sock -H 'Content-Type: application/json' http://localhost/containers/minio/start
I tried to put them in the top of the json and the HostConfig "sub entry"
"Args": "server --address 192.168.150.3:80 /export",
but when I inspect the arguments are not there.
In the documentation there are examples only when you inspect a container and see the arguments.
Is there a way to pass Args within the json file or when you start the container with curl and a payload ("docker run" is excluded) ?
UPDATE:
Solution is to list all arguments in double quotes in the array.
"Cmd": [
"server" ,"--address", "192.168.100.8:8888", "/export"
],
The API has two attributes in JSON
"Cmd": [
"date"
],
"Entrypoint": "",
You need to change the Cmd array to pass the arguments you want

Base64 decoding failed for \ "ZKgdjfk......... in Google Cloud speech API

My request.sh code:
#!/bin/bash
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Create a request file with our JSON request in the current directory
FILENAME="request-"`date +"%s".json`
cat <<EOF > $FILENAME
{
"config": {
"encoding":"FLAC",
"sampleRateHertz":16000,
"profanityFilter": true,
"languageCode": "en-US",
"speechContexts": {
"phrases": ['']
},
"maxAlternatives": 1
},
"audio": {
"content":
}
}
EOF
# Update the languageCode parameter if one was supplied
if [ $# -eq 1 ]
then
sed -i 'audio.base64' -e "s/en-US/$1/g" $FILENAME
fi
# Record an audio file, base64 encode it, and update our request object
read -p "Press enter when you're ready to record" rec
if [ -z $rec ]; then
rec --channels=1 --bits=16 --rate=16000 audio.flac trim 0 3
echo \"`base64 audio.flac`\" > audio.base64
sed -i 'audio.base64' -e '/ "content":/r audio.base64' $FILENAME
fi
echo Request "file" $FILENAME created:
head -7 $FILENAME # Don't print the entire file because there's a giant base64 string
echo $'\t"Your base64 string..."\n\x00\x00}\n}'
# Call the speech API (requires an API key)
read -p $'\nPress enter when you\'re ready to call the Speech API' var
if [ -z $var ];
then
echo "Running the following curl command:"
echo "curl -s -X POST -H 'Content-Type: application/json' --data-binary #${FILENAME} https://speech.googleapis.com/v1/speech:recognize?key=API_KEY"
curl -s -X POST -H "Content-Type: application/json" --data-binary #${FILENAME} https://speech.googleapis.com/v1/speech:recognize?key=MY_API_KEY
fi
I am getting the error
{
"error": {
"code": 400,
"message": "Invalid value at 'audio.content' (TYPE_BYTES), Base64 decoding failed for \"ZkxhQwAAACAAA....\"",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "audio.content",
"description": "Invalid value at 'audio.content' (TYPE_BYTES), Base64 decoding failed for \"Zkxh...
When I executed request.sh bash file, the above error rises.
How can I solve this error? or Does anyone else have a problem like me?
Looks like you'v tried the code from Sara Robinson on Hakernoon too.
I had the same problem and this post from ZodiacLeo123 helped me.
You have to add the the "-w" flag
base64 -w 0 audio.flac
This removes extra new lines.

ICINGA2 API Not making host modification

i have problem with the API of ICINGA2.
i'm trying to add new variables with the POST call ,
i'm getting the required result,
But ICINGA2 didn't add the new var.
According to documentation:
http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/icinga2-api
With the following API, i creates all our hosts in vienna :
curl -k -s -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/hosts/server.example.com' \
-d '{ "templates": [ "generic-host" ], "attrs": { "zone": "Vienna", "address": "180.33.1.123", "check_command": "hostalive", "vars.os" : "Linux", "vars.agent" : "ssh" } }' \
| python -m json.tool
While this part works as expected,
The problem is once host created, i need to add various vars for different servers.
for example
Adding of the variable: "vars.servicename" : "DHCP_Servers"
If i'm going back to the documentation, the below API that will need to be execute:
curl -k -s -u root:icinga -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/objects/hosts/server.example.com' \
-d '{ "templates": [ "generic-host" ], "attrs": { "zone": "Vienna", "address": "180.33.1.123", "check_command": "hostalive", "vars.os" : "Linux", "vars.agent" : "ssh", "vars.servicename" : "DHCP_Servers" } }' \
| python -m json.tool
When i ran the API , as expected i'm getting back:
{
"results": [
{
"code": 200.0,
"name": "server.example.com",
"status": "Attributes updated.",
"type": "Host"
}
]
}
But there is no changes that taking place on ICINGA/ host file.
Obviously the same user as in my inbox and the forums (https://monitoring-portal.org/index.php?thread/37160-adding-vars-with-api/&postID=234885#post234885) lately. Leaving this as a note here as it might help others to see why it does not work. That feature is just not implemented as it involves storing the applied changes, do a rollback, and re-apply. Not as simple as it sounds.
https://dev.icinga.org/issues/11501