Skip to content

Instantly share code, notes, and snippets.

@maxlath
Last active January 13, 2021 20:30
Show Gist options
  • Select an option

  • Save maxlath/18ab1f0eaf5bf5201fd392d7bb988e45 to your computer and use it in GitHub Desktop.

Select an option

Save maxlath/18ab1f0eaf5bf5201fd392d7bb988e45 to your computer and use it in GitHub Desktop.

Revisions

  1. maxlath revised this gist Jan 13, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion inv_add_publisher.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ add_claim(){
    uri=$1
    property=$2
    value=$3
    curl -s -XPUT "$host/api/entities?action=update-claim" -H "Cookie: $INV_SESSION_COOKIES" -H "Content-Type: application/json" -d "{\"uri\":\"${uri}\",\"property\":\"${property}\",\"new-value\":\"${value}\"}"
    curl -s -XPUT "https://inventaire.io/api/entities?action=update-claim" -H "Cookie: $INV_SESSION_COOKIES" -H "Content-Type: application/json" -d "{\"uri\":\"${uri}\",\"property\":\"${property}\",\"new-value\":\"${value}\"}"
    }

    add_publisher(){
  2. maxlath revised this gist Jan 13, 2021. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions inv_add_publisher.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    // Use your username and password to get session cookies
    # Use your username and password to get session cookies
    INV_USERNAME=foo
    INV_PASSWORD=bar
    INV_SESSION_COOKIES=$(curl -v 'https://inventaire.io/api/auth?action=login' -d "{\"username\":\"$INV_USERNAME\",\"password\":\"$INV_PASSWORD\"}" 2>&1 | grep 'Set-Cookie: inventaire:session' | awk '{print $3}' | xargs echo)
    @@ -14,4 +14,5 @@ add_publisher(){
    inv_add_claim "$1" wdt:P123 "$2"
    }

    add_publisher inv:633835fc12ba489cdb202d0d63bde7d8 wd:Q1285349
    add_publisher inv:1b7b119485923797ed33e2fd292ae299 wd:Q1285349
    add_publisher inv:3fdcb00a816ff62049c076960eef2080 wd:Q1285349
  3. maxlath renamed this gist Jan 13, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. maxlath created this gist Jan 13, 2021.
    17 changes: 17 additions & 0 deletions inv_add_publisher
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // Use your username and password to get session cookies
    INV_USERNAME=foo
    INV_PASSWORD=bar
    INV_SESSION_COOKIES=$(curl -v 'https://inventaire.io/api/auth?action=login' -d "{\"username\":\"$INV_USERNAME\",\"password\":\"$INV_PASSWORD\"}" 2>&1 | grep 'Set-Cookie: inventaire:session' | awk '{print $3}' | xargs echo)

    add_claim(){
    uri=$1
    property=$2
    value=$3
    curl -s -XPUT "$host/api/entities?action=update-claim" -H "Cookie: $INV_SESSION_COOKIES" -H "Content-Type: application/json" -d "{\"uri\":\"${uri}\",\"property\":\"${property}\",\"new-value\":\"${value}\"}"
    }

    add_publisher(){
    inv_add_claim "$1" wdt:P123 "$2"
    }

    add_publisher inv:633835fc12ba489cdb202d0d63bde7d8 wd:Q1285349