Created
May 25, 2021 13:45
-
-
Save duckfez/b4660c707bf406ae5e2d1a83097812cb 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 | |
SUB=<mysub> | |
RG=<myrg> | |
API_VER=2021-01-01 | |
HOST=https://management.usgovcloudapi.net | |
BUCKET=<mybucket> | |
BT=<mybearertoken> | |
URL="$HOST/subscriptions/$SUB/resourceGroups/$RG/providers/Microsoft.Storage/storageAccounts/$BUCKET/blobServices/default?api-version=$API_VER" | |
# Test 1 - can we access the bucket at all? | |
# Is bearer token good etc | |
echo "Attempt to read settings" | |
curl --silent -H "Authorization: Bearer ${BT}" "$URL" | jq | |
declare -a TESTS | |
declare -a EXPLAINS | |
# Test 0 attempt to set all the attributes | |
EXPLAIN[0]="Attempt to set all the attributes" | |
TESTS[0]='{"properties":{"cors":{},"defaultServiceVersion":"2019-07-07","deleteRetentionPolicy":{"enabled":true,"days":30},"isVersioningEnabled":true,"changeFeed":{"enabled":false},"containerDeleteRetentionPolicy":{"enabled":true,"days":30},"lastAccessTimeTrackingPolicy":{"enable":false}}}' | |
# Test 1 let's back off to just a couple of things | |
EXPLAIN[1]="Just defaultServiceVersion and deleteRetentionPolicy" | |
TESTS[1]='{"properties":{"cors":{},"defaultServiceVersion":"2019-07-07","deleteRetentionPolicy":{"enabled":true,"days":30}}}' | |
# Test 2 let's add some more back | |
EXPLAIN[2]="Add isVersioningEnabled" | |
TESTS[2]='{"properties":{"cors":{},"defaultServiceVersion":"2019-07-07","deleteRetentionPolicy":{"enabled":true,"days":30},"isVersioningEnabled":true}}' | |
# Test 3 and some more | |
EXPLAIN[3]="Add changeFeed" | |
TESTS[3]='{"properties":{"cors":{},"defaultServiceVersion":"2019-07-07","deleteRetentionPolicy":{"enabled":true,"days":30},"isVersioningEnabled":true,"changeFeed":{"enabled":false}}}' | |
# Test 4 and still more | |
EXPLAIN[4]="Add containerDeleteRetentionPolicy" | |
TESTS[4]='{"properties":{"cors":{},"defaultServiceVersion":"2019-07-07","deleteRetentionPolicy":{"enabled":true,"days":30},"isVersioningEnabled":true,"changeFeed":{"enabled":false},"containerDeleteRetentionPolicy":{"enabled":true,"days":30}}}' | |
# Test 5 focus on containerdeleteretentionpolicy | |
EXPLAIN[5]="JUST containerDeleteRetentionPolicy" | |
TESTS[5]='{"properties":{"containerDeleteRetentionPolicy":{"enabled":true,"days":30}}}' | |
# Test 6 focus on lastaccesstimetrackingpolicy | |
EXPLAIN[6]="JUST lastAccessTimeTrackingPolicy" | |
TESTS[6]='{"properties":{"lastAccessTimeTrackingPolicy":{"enable":false}}}' | |
C=0 | |
for T in ${TESTS[@]}; do | |
echo "======================================================" | |
echo "${EXPLAIN[$C]}" | |
curl --silent -X PUT -H 'Content-type: application/json' -H "Authorization: Bearer ${BT}" "$URL" -d "$T" | jq | |
C=$(( $C + 1 )) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment