-
-
Save adborden/0ea2fd243910b711e41a9f36a740fa81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Adds the user to the list of organizations as the specified role. | |
# | |
# Usage ./org_membership.sh <email> <role> < subagencies.txt | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
function organization_member_create () { | |
local username=$1 | |
local organization=$2 | |
local role=$3 | |
payload=$(mktemp) | |
cat <<EOF > "$payload" | |
{"id":"$organization","username":"$username","role":"$role"} | |
EOF | |
#--data "id=$organization" \ | |
#--data "username=$username" \ | |
#--data "role=$role" \ | |
curl -vvvv --fail -H "Authorization: $CKAN_API_KEY" -H "Cookie: auth_tkt=1" \ | |
--data-binary "@$payload" \ | |
-H "Content-Type: application/json;charset=utf-8" \ | |
'https://inventory.data.gov/api/3/action/organization_member_create' | |
rm "$payload" | |
} | |
username=$1 | |
role=${2:-member} | |
while read organization; do | |
organization_member_create "$username" "$organization" "$role" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment