Reply

Help with how to update sharedrecordgroup via API call

[ Edited ]
New Member
Posts: 3
2624     0

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="usernameSmiley Tongueassword"

__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/ZG5zLnNyZyQuc3JnX3Jvb3QuMTQSmiley Very HappyMARC%20Monitoring",
"zone_associations": [
"achievercircle.com"
]
},
{
"_ref": "sharedrecordgroup/ZG5zLnNyZyQuc3JnX3Jvb3QuMTUSmiley Very HappyMARC%20Reject",
"zone_associations": [
"aahmail.com"
]
}
]
SHOW only results from the DMARC Monitoring group
Shared group: sharedrecordgroup/ZG5zLnNyZyQuc3JnX3Jvb3QuMTQSmiley Very HappyMARC%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)"
}

Re: Help with how to update sharedrecordgroup via API call

[ Edited ]
Moderator
Moderator
Posts: 315
2625     0

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

New Member
Posts: 3
2625     0

Fantastic! Thank you.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin