Created
January 21, 2025 19:22
-
-
Save TiloGit/064cfd5e4be4f132e0eb123860d2d674 to your computer and use it in GitHub Desktop.
Revisions
-
TiloGit created this gist
Jan 21, 2025 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ ######################### ##login to source box account boxaccesstoken=$(python /mnt/c/myscripts/box-admin-scripts/box-login-read-json-dynamic.py --jsonpath /mnt/c/myscripts/box-admin-scripts/box-demo-old.json) ##read and copy metadata template to other box account myTemplateName="purchaseRequisition" ##get source metadata def. sourceJson=$(curl -s -X GET "https://api.box.com/2.0/metadata_templates/enterprise/$myTemplateName/schema" \ -H "Authorization: Bearer $boxaccesstoken") ##remove id and other fields not needed for new template creation #echo $sourceJson | jq 'del(.id, .type, .fields[].id , .fields[].options[]?.id)' modsourceJson=$(jq 'del(.id, .type, .fields[].id , .fields[].options[]?.id)' <<< "$sourceJson" ) modsourceJson2=$(jq '.scope = "enterprise"' <<< "$modsourceJson" ) #echo $modsourceJson2 | jq . ##now login to new box account and apply. boxaccesstoken=$(python /mnt/c/myscripts/box-admin-scripts/box-login-read-json-dynamic.py --jsonpath /mnt/c/myscripts/box-admin-scripts/box-demo-new.json) #create metadata template copy curl -X POST "https://api.box.com/2.0/metadata_templates/schema" \ -H "Authorization: Bearer $boxaccesstoken" \ -H "Content-Type: application/json" \ --data "$modsourceJson2" ###end of create metadata template ##check new metadata templates properties (to csv) curl -s -X GET "https://api.box.com/2.0/metadata_templates/enterprise/$myTemplateName/schema" \ -H "Authorization: Bearer $boxaccesstoken" | jq -r '.fields[] | [.displayName, .key, .type, .hidden] | @csv'