LMLPHP后院

aliyun cli 操作示例技术

maybe yes 发表于 2022-06-05 12:21

不得不说,阿里云在 api 方面还是努了一点力的,至少把接口做的好用一点了,更加从用户的角度考虑问题了。

$ ./aliyun alidns DescribeDomainRecords --DomainName a.com
{
	"DomainRecords": {
		"Record": [
			{
				"DomainName": "",
				"Line": "default",
				"Locked": false,
				"RR": "",
				"RecordId": "",
				"Status": "ENABLE",
				"TTL": 600,
				"Type": "A",
				"Value": "192.168.1.1",
				"Weight": 1
			},
			{
				"DomainName": "",
				"Line": "default",
				"Locked": false,
				"RR": "*",
				"RecordId": "",
				"Status": "ENABLE",
				"TTL": 600,
				"Type": "A",
				"Value": "",
				"Weight": 1
			},
			{
				"DomainName": "",
				"Line": "default",
				"Locked": false,
				"RR": "@",
				"RecordId": "",
				"Status": "ENABLE",
				"TTL": 600,
				"Type": "A",
				"Value": "",
				"Weight": 1
			}
		]
	},
	"PageNumber": 1,
	"PageSize": 20,
	"RequestId": "",
	"TotalCount": 3
}

$
$ ./aliyun alidns DescribeDomainRecords --SubDomainName a.com
ERROR: '--SubDomainName' is not a valid parameter or flag. See `aliyun help alidns DescribeDomainRecords`.
$ ./aliyun alidns DescribeDomainRecords --SubDomain 
ERROR: '--SubDomain' is not a valid parameter or flag. See `aliyun help alidns DescribeDomainRecords`.
$ ./aliyun alidns DescribeSubDomainRecords --SubDomain 
	"DomainRecords": {
		"Record": [
			{
				"DomainName": "",
				"Line": "default",
				"Locked": false,
				"RR": "",
				"RecordId": "",
				"Status": "ENABLE",
				"TTL": 600,
				"Type": "A",
				"Value": "192.168.1.1",
				"Weight": 1
			}
		]
	},
	"PageNumber": 1,
	"PageSize": 20,
	"RequestId": "",
	"TotalCount": 1
}
$ ./aliyun alidns UpdateDomainRecord --RecordId * --RR * --Type A --Value 168.168.1.1 --Line default
{
	"RecordId": "",
	"RequestId": ""
}
$ ./aliyun alidns DescribeSubDomainRecords --SubDomain a.com
{
	"DomainRecords": {
		"Record": [
			{
				"DomainName": "",
				"Line": "default",
				"Locked": false,
				"RR": "",
				"RecordId": "",
				"Status": "ENABLE",
				"TTL": 600,
				"Type": "A",
				"Value": "168.168.1.1",
				"Weight": 1
			}
		]
	},
	"PageNumber": 1,
	"PageSize": 20,
	"RequestId": "",
	"TotalCount": 1
}

特点就是 RecordId 居然没有发生变化,接口还是比较好用的,不会出现修改的时候需要指定 RR 去除后缀,而实际响应的列表二级域名有后缀的情况。它这个做的更加方便,只需要指定 RecordId 即可。

2024-12-22 11:48:04 1734839284 0.005256