如何使用 Softlayer API 和 Powershell 删除 DNS 记录



我需要编写一个PowerShell脚本,该脚本使用Softlayer REST API从Softlayer cloud中删除DNS记录。

以下命令应该达到我的目的。我$headers设置正确。我的问题与$uri$jsonObject有关.

Invoke-WebRequest -Uri $uri -Headers $headers -Method POST -ContentType application/json -Body $jsonObject 

谁能给我一个$jsonObject$uri值的例子?$uri应该如下所示吗?如果是,Object.json是什么,我需要定义它吗?

$uri = "https://api.service.softlayer.com/rest/v3.1/SoftLayer_Dns_Domain_ResourceRecord/deleteObject/Object.json"

尝试遵循示例

slcli --format=json call-api SoftLayer_Dns_Domain_ResourceRecord deleteObject --id 123456789

123456789数据应随您的 DNS 域 ID 而更改

有关更多信息,您能否查看链接 https://softlayer-api-python-client.readthedocs.io/en/latest/cli/call_api/

我希望它有所帮助。

我发现了如何: $uri="https://api.softlayer.com/rest/v3/SoftLayer_Dns_Domain/$domainID/getResourceRecords.json">

下面将返回一个包含我们域中所有记录的 json 文件: Invoke-WebRequest -uri $uri -headers $headers -Method GET -ContentType application/json

从收到的json文件中,我们可以提取要删除的记录的记录ID($recordID在下面(,然后在下面运行: $deleteResoutceURI="https://api.softlayer.com/rest/v3/SoftLayer_Dns_Domain_ResourceRecord/$recordID/deleteObject.json">

Invoke-WebRequest -uri $deleteResoutceURI -headers $headers -Method POST -ContentType application/json

最新更新