From 1cda3fd1d5f26496d0514d3a542dcf76e47f9bcd Mon Sep 17 00:00:00 2001 From: Victor Ng Date: Thu, 28 Nov 2019 20:25:23 -0500 Subject: [PATCH] added cURL commands to instrument RS buckets in a demo script --- scripts/bot_signoff.sh | 72 +++++++++++++++++++++++++++++++++ scripts/create-bucket.sh | 9 ----- scripts/read_remote_settings.sh | 4 -- scripts/write_exp_bucket.sh | 13 ------ 4 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 scripts/bot_signoff.sh delete mode 100644 scripts/create-bucket.sh delete mode 100644 scripts/read_remote_settings.sh delete mode 100644 scripts/write_exp_bucket.sh diff --git a/scripts/bot_signoff.sh b/scripts/bot_signoff.sh new file mode 100644 index 0000000..ecfbeba --- /dev/null +++ b/scripts/bot_signoff.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +# Create a cfr-bot with a dummy password for local testing +SERVER=http://localhost:8888/v1 + +curl -X PUT ${SERVER}/accounts/cfr-bot \ + -d '{"data": {"password": "botpass"}}' \ + -H 'Content-Type:application/json' + +BASIC_AUTH=cfr-bot:botpass + +# Create 3 collections +# * main/cfr-models +# * main/cfr-experiment +# * main/cfr-control + +curl -X PUT ${SERVER}/buckets/main/collections/cfr-models \ + -H 'Content-Type:application/json' \ + -u ${BASIC_AUTH} + +curl -X PUT ${SERVER}/buckets/main/collections/cfr-experiment \ + -H 'Content-Type:application/json' \ + -u ${BASIC_AUTH} + +curl -X PUT ${SERVER}/buckets/main/collections/cfr-control \ + -H 'Content-Type:application/json' \ + -u ${BASIC_AUTH} + +# Add the bot to editor role for 3 collections: +# * main/cfr-models +# * main/cfr-experiment +# * main/cfr-control + +curl -X PATCH $SERVER/buckets/main/groups/cfr-models-editors \ + -H 'Content-Type:application/json-patch+json' \ + -d '[{ "op": "add", "path": "/data/members/0", "value": "account:cfr-bot" }]' \ + -u ${BASIC_AUTH} + +curl -X PATCH $SERVER/buckets/main/groups/cfr-experiment-editors \ + -H 'Content-Type:application/json-patch+json' \ + -d '[{ "op": "add", "path": "/data/members/0", "value": "account:cfr-bot" }]' \ + -u ${BASIC_AUTH} + +curl -X PATCH $SERVER/buckets/main/groups/cfr-control-editors \ + -H 'Content-Type:application/json-patch+json' \ + -d '[{ "op": "add", "path": "/data/members/0", "value": "account:cfr-bot" }]' \ + -u ${BASIC_AUTH} + +# Add the bot to reviewer role for 3 collections: +# * main/cfr-models +# * main/cfr-experiment +# * main/cfr-control + +curl -X PATCH $SERVER/buckets/main/groups/cfr-models-reviewers \ + -H 'Content-Type:application/json-patch+json' \ + -d '[{ "op": "add", "path": "/data/members/0", "value": "account:cfr-bot" }]' \ + -u ${BASIC_AUTH} +curl -X PATCH $SERVER/buckets/main/groups/cfr-experiment-reviewers \ + -H 'Content-Type:application/json-patch+json' \ + -d '[{ "op": "add", "path": "/data/members/0", "value": "account:cfr-bot" }]' \ + -u ${BASIC_AUTH} +curl -X PATCH $SERVER/buckets/main/groups/cfr-control-reviewers \ + -H 'Content-Type:application/json-patch+json' \ + -d '[{ "op": "add", "path": "/data/members/0", "value": "account:cfr-bot" }]' \ + -u ${BASIC_AUTH} + +# Generate some dummy data in the cfr-models bucket + +curl -X PUT ${SERVER}/buckets/main-workspace/collections/cfr-experiment/records/5ba22305-6a9e-4f2b-beee-0a0a84d44708 \ + -H 'Content-Type:application/json' \ + -d "{\"data\": {\"property\": 321.1}}" \ + -u ${BASIC_AUTH} --verbose diff --git a/scripts/create-bucket.sh b/scripts/create-bucket.sh deleted file mode 100644 index 995d153..0000000 --- a/scripts/create-bucket.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -BASIC_AUTH=admin:s3cr3t -BUCKET_NAME=cfr-experiment-1 - -curl -X PUT ${SERVER}/buckets/${BUCKET_NAME} \ - -d '{"permissions": {"read": ["system.Everyone"], "collection:create": ["system.Authenticated"]}}' \ - -H 'Content-Type:application/json' \ - -u $BASIC_AUTH diff --git a/scripts/read_remote_settings.sh b/scripts/read_remote_settings.sh deleted file mode 100644 index ac4618b..0000000 --- a/scripts/read_remote_settings.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -CID=cfr -SERVER=https://firefox.settings.services.mozilla.com/v1 -curl ${SERVER}/buckets/main/collections/${CID}/records diff --git a/scripts/write_exp_bucket.sh b/scripts/write_exp_bucket.sh deleted file mode 100644 index 67c92b6..0000000 --- a/scripts/write_exp_bucket.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -CID=cfr-experiment-20191108 -SERVER=http://localhost:8888/v1/ -BASIC_AUTH=admin:s3cr3t - -curl -X PUT ${SERVER}/buckets/main/collections/${CID} \ - -H 'Content-Type:application/json' \ - -u ${BASIC_AUTH} - -# curl -X POST ${SERVER}/buckets/main/collections/${CID}/records \ -# -d '{"data": {"title": "example"}}' \ -# -H 'Content-Type:application/json' \ -# -u ${BASIC_AUTH}