I need to capture all the spaces/chat-rooms they use and ensure the new accounts get connected to all those spaces. I can use curl to call the service Spark API and get the list of spaces, and process that with jq to put it in a respectable format. What I end up with is a series of 50 to 900 (depending on the use) JSON objects (one per space/room).
{
"items":[
{
"id":"Y2lzY29zcGFyazovL3VzL1JPT00vNGY0Y2Q5NDAtN2JkZi0xMWU4LThiMjMtMTU0YzAyNTI0YzBh",
"title":"(CISCO INTERNAL): FTB - CMS Opportunity",
"type":"group",
"isLocked":false,
"lastActivity":"2018-06-29T21:05:55.994Z",
"creatorId":"Y2lzY29zcGFyazovL3VzL1BFT1BMRS9kMWI3MDRhNS05ZmU0LTQ3MTYtOGY2Zi02OGEyNjVjZGQ5YzM",
"created":"2018-06-29T20:59:27.316Z"
},
{
"id":"Y2lzY29zcGFyazovL3VzL1JPT00vMTQxODk5MTAtN2JiYS0xMWU4LThiOWUtMjMwOWM4Y2NiYWMz",
"title":"USU Cisco Webex EDU Program",
"type":"group",
"isLocked":true,
"lastActivity":"2018-06-29T19:46:14.993Z",
"creatorId":"Y2lzY29zcGFyazovL3VzL1BFT1BMRS8wZThjMzg3Yy0zNzc5LTRlYTEtYmY2My1mNzZmMDJkYzVjM2M",
"created":"2018-06-29T16:32:56.609Z"
},
{
"id":"Y2lzY29zcGFyazovL3VzL1JPT00vZjYyNDg1NjAtNzg5Yy0xMWU4LTlmYzItNGZhYzQwZWE4MTA4",
"title":"Darren TeamSpace Space",
"type":"group",
"isLocked":false,
"lastActivity":"2018-06-26T15:00:03.332Z",
"teamId":"Y2lzY29zcGFyazovL3VzL1RFQU0vZWQ5Mzc1ZDAtZjE1MC0xMWU1LWFjNWUtNTNiMzQxMDkxMTU1",
"creatorId":"Y2lzY29zcGFyazovL3VzL1BFT1BMRS83YTBkMTJiMS1lODMxLTRkNmItYTAzMS0xMDU4Y2UwOTAwZTU",
"created":"2018-06-25T17:26:57.561Z"
}
]
}
What I'd like to do here is create a quick and dirty script that can then process this JSON file in a loop, pulling the keys in as variables
(items.id = $id, items.title = $title, etc.)
with the associated values from the file, so I can perform some basic "if then else" evaluations (check if isLocked is true or false) and then execute some other API calls using the other variables. For some reason, and it's probably my lack of familiarity with jq, I can't get the loop and variable extraction to work properly.