Skip to content

Instantly share code, notes, and snippets.

@gfoo
Last active December 7, 2018 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfoo/aa88b83f851cb6c4d4da97df0d35fabd to your computer and use it in GitHub Desktop.
Save gfoo/aa88b83f851cb6c4d4da97df0d35fabd to your computer and use it in GitHub Desktop.
Create permission
{
"@type": "onto:Collection",
"rdfs:label": "Test",
"knora-api:attachedToProject": {
"@id": "http://rdfh.ch/projects/0113"
},
"onto:collectionHasTitle": {
"@type": "knora-api:TextValue",
"knora-api:valueAsString": "Test"
},
"onto:collectionHasUrlElement": {
"@type": "knora-api:TextValue",
"knora-api:valueAsString": "test"
},
"onto:hasDiffusionType": {
"@type": "knora-api:BooleanValue",
"knora-api:booleanValueAsBoolean": false
},
"onto:hasOwnerValue": {
"@type": "knora-api:LinkValue",
"knora-api:linkValueHasTargetIri": {
"@id": "@OWNER@"
}
},
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"knora-api": "http://api.knora.org/ontology/knora-api/v2#",
"onto": "http://0.0.0.0:3333/ontology/0113/lumieres-lausanne/v2#"
}
}
alias urlencode='python2 -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
res_id=$(curl -s -u admin_test@unil.ch:test -X POST -H "Content-Type: application/json" -d @user.json http://localhost:3333/v2/resources |jq -r '."@id"')
echo $res_id
curl -s http://localhost:3333/v2/resources/$(urlencode $res_id)
sed -e 's,@OWNER@,'"${res_id}"',g' collection.json | curl -s -u gilles.faucherand@unil.ch:test -X POST -H "Content-Type: application/json" -d @- http://localhost:3333/v2/resources
{
"@type": "onto:User",
"rdfs:label": "Test",
"knora-api:attachedToProject": {
"@id": "http://rdfh.ch/projects/0113"
},
"onto:isKnoraUser": {
"@type": "knora-api:UriValue",
"knora-api:uriValueAsUri": {
"@type": "xsd:anyURI",
"@value": "http://rdfh.ch/users/lumieres-lausanne-gfaucherand"
}
},
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"knora-api": "http://api.knora.org/ontology/knora-api/v2#",
"onto": "http://0.0.0.0:3333/ontology/0113/lumieres-lausanne/v2#"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment