- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Help with how to update sharedrecordgroup via API call
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2021 09:18 AM - edited 10-06-2021 10:28 AM
I'm trying to write automation that will update the DMARC (TXT) records for a couple of thousand domains. We are using shared records.
I'm able to successfully query and then receive my zones that are associated with a particular sharedrecordgroup.
__gridmaster="gridmaster.somedomain.com"
__creds="usernameassword"
__tokenfile=${__progdir}/tokenfile.txt
echo GET zone associations for all SHARED_RECORD_GROUPs
curl -k1 -u "${__creds}" -H "Content-Type: application/json" -X GET https://${__gridmaster}/wapi/v2.10/sharedrecordgroup?_return_fields=zone_associations > ${__tokenfile}
However, I'm unable to PUT any updates. The documenation is sketchy and apparently not a lot poeple are doing this. Here's where I'm at, problem code is in red:
echo SHOW only results from the DMARC Monitoring group
__sharedgroupref=$(grep "_ref" ${__tokenfile} | grep "DMARC" | grep "Monitoring" | awk -F\" '{print $4}')
echo "Shared group: "${__sharedgroupref}
echo PUT updates to the DMARC Monitoring group
curl -k1 -u "${__creds}" -H "Content-Type: application/json" -X PUT https://${__gridmaster}/wapi/v2.10/${__sharedgroupref} -d '{ "sharedrecordgroup": "DMARC Monitoring" [ "achievercircle.com", "aahmail.com" ] }'
Output:
GET zone associations for all SHARED_RECORD_GROUPs
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 347 0 347 0 0 201 0 --:--:-- 0:00:01 --:--:-- 201
[
{
"_ref": "sharedrecordgroup/ZG5zLnNyZyQuc3JnX3Jvb3QuMTQMARC%20Monitoring",
"zone_associations": [
"achievercircle.com"
]
},
{
"_ref": "sharedrecordgroup/ZG5zLnNyZyQuc3JnX3Jvb3QuMTUMARC%20Reject",
"zone_associations": [
"aahmail.com"
]
}
]
SHOW only results from the DMARC Monitoring group
Shared group: sharedrecordgroup/ZG5zLnNyZyQuc3JnX3Jvb3QuMTQMARC%20Monitoring
PUT updates to the DMARC Monitoring group
{ "Error": "AdmConProtoError: JSON Decoding: Expecting , delimiter: line 1 column 42 (char 42)",
"code": "Client.Ibap.Proto.JSONDecoding",
"text": "JSON Decoding: Expecting , delimiter: line 1 column 42 (char 42)"
}
Solved! Go to Solution.
Re: Help with how to update sharedrecordgroup via API call
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2021 07:52 PM - edited 10-08-2021 08:21 PM
Here's a handful of examples, hopefully they are helpful
Create a shared record group (compact url format)
curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.10/sharedrecordgroup?name=MY_SRG'
returns the reference
"sharedrecordgroup/ZG5zLnNyZyQuc3JnX3Jvb3QuMTQ:MY_SRG"
Create a new TXT record (json format)
curl -k1 -u admin:infoblox -H 'Content-Type: application/json' -X POST 'https://192.168.1.2/wapi/v2.10/sharedrecord:txt' -d \ '{ "name" : "my_dmarc", "shared_record_group" : "MY_SRG", "text" : "All that is gold does not glitter, Not all those who wander are lost" }'
returns the reference
"sharedrecord:txt/ZG5zLmJpbmRfdHh0JC5zcmdfcm9vdC4xNC5teV9kbWFyYy4iQWxsIiAidGhhdCIgImlzIiAiZ29sZCIgImRvZXMiICJub3QiICJnbGl0dGVyLCIgIk5vdCIgImFsbCIgInRob3NlIiAid2hvIiAid2FuZGVyIiAiYXJlIiAibG9zdCI:my_dmarc/MY_SRG"
Search for shared TXT records
curl -k1 -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.10/sharedrecord:txt'\
returns
[ { "_ref": "sharedrecord:txt/ZG5zLmJpbmRfdHh0JC5zcmdfcm9vdC4xNC5teV9kbWFyYy4iQWxsIiAidGhhdCIgImlzIiAiZ29sZCIgImRvZXMiICJub3QiICJnbGl0dGVyLCIgIk5vdCIgImFsbCIgInRob3NlIiAid2hvIiAid2FuZGVyIiAiYXJlIiAibG9zdCI:my_dmarc/MY_SRG", "name": "my_dmarc", "shared_record_group": "MY_SRG", "text": "All that is gold does not glitter, Not all those who wander are lost" } ]
Update the existing shared TXT record with different text
curl -k1 -u admin:infoblox -H 'Content-Type: application/json' -X PUT 'https://192.168.1.2/wapi/v2.10/sharedrecord:txt/ZG5zLmJpbmRfdHh0JC5zcmdfcm9vdC4xNC5teV9kbWFyYy4iQWxsIiAidGhhdCIgImlzIiAiZ29sZCIgImRvZXMiICJub3QiICJnbGl0dGVyLCIgIk5vdCIgImFsbCIgInRob3NlIiAid2hvIiAid2FuZGVyIiAiYXJlIiAibG9zdCI:my_dmarc/MY_SRG' -d \ '{ "text" : "All that is cold does not shiver, Not all those who dander are frost" }'
Find our nameserver group, return its reference and any zone associations
curl -k1 -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.10/sharedrecordgroup?name=MY_SRG&_return_fields%2b=zone_associations'
returns
[ { "_ref": "sharedrecordgroup/ZG5zLnNyZyQuc3JnX3Jvb3QuMTQ:MY_SRG", "name": "MY_SRG", "zone_associations": [] } ]
Update the shared record group with a few zone associations.
Note there is a limitation, we cannot specify the DNS view in the API call, so this will fail if the zone is defined in multiple DNS views.
Also note that the full list of zones must be sent each time the list is updated.
curl -k1 -u admin:infoblox -H 'Content-Type: application/json' -X PUT 'https://10.9.16.6/wapi/v2.10/sharedrecordgroup/ZG5zLnNyZyQuc3JnX3Jvb3QuMTQ:MY_SRG' -d \ '{ "zone_associations": [ "example.com", "example.org", "example.net" ] }'
returns the ref of the SRG
"sharedrecordgroup/ZG5zLnNyZyQuc3JnX3Jvb3QuMTQ:MY_SRG
Re: Help with how to update sharedrecordgroup via API call
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2021 11:35 AM
Fantastic! Thank you.