{"id":332923,"date":"2022-05-09T03:00:07","date_gmt":"2022-05-09T03:00:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=332923"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=332923","title":{"rendered":"<span>Golang-\u043a\u043b\u0438\u0435\u043d\u0442 NIC.ru<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0421\u043f\u0435\u0448\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u0435-\u043a\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439. Golang-\u043a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f NIC.ru API.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0435\u0441\u043d\u0430\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 nic.ru, \u0442\u0430\u043a \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438, \u0443\u0432\u0435\u0440\u0435\u043d, \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f DNS-\u0443\u0441\u043b\u0443\u0433\u0430\u043c\u0438 nic.ru, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u043d\u0435 \u0442\u0430\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043a\u0430\u043a \u043c\u044b, \u043d\u043e, \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, \u0434\u043b\u044f \u043d\u0430\u0441 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u0440\u0430\u043d\u0435\u0435 \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0430 Python, \u043d\u043e, \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0435\u0437\u0436\u0430\u0435\u043c \u043d\u0430 Go, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u043b\u043e. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0443-\u0442\u043e \u044d\u0442\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u0436\u0438\u0437\u043d\u044c \/ \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f.<\/p>\n<h2>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f python <a href=\"https:\/\/pypi.org\/project\/nic-api\/\" rel=\"noopener noreferrer nofollow\">https:\/\/pypi.org\/project\/nic-api\/<\/a><\/p>\n<p>\u0415\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0430\u0448 \u043a\u043e\u043b\u043b\u0435\u0433\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434, \u043d\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e, \u0447\u0442\u043e \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0438 \u043d\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435, \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043d\u0435\u043b\u044c\u0437\u044f \u044d\u0442\u043e \u043d\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c.<\/p>\n<p>\u0424\u043e\u0440\u043c\u0430\u0442 API \u043e\u043f\u0438\u0441\u0430\u043d <a href=\"https:\/\/www.nic.ru\/help\/upload\/file\/API_DNS-hosting.pdf\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>, \u0432\u0435\u0441\u0435\u043b\u043e\u0433\u043e \u0442\u0430\u043c \u043c\u0430\u043b\u043e, \u0432\u0441\u0451 \u043d\u0430 xml, \u043d\u043e, \u0443\u043d\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u044e\u0442.<\/p>\n<h2>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/p>\n<h3>Request<\/h3>\n<p>\u042d\u0442\u043e \u043e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<pre><code class=\"go\">type Request struct { XMLName xml.Name `xml:\"request\"` Text    string   `xml:\",chardata\"` RrList  *RrList  `xml:\"rr-list\"` }<\/code><\/pre>\n<h3>RrList<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<pre><code class=\"go\">type RrList struct { Text string `xml:\",chardata\"` Rr   []*RR  `xml:\"rr\"` }<\/code><\/pre>\n<h3>RR<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 DNS<\/p>\n<pre><code class=\"go\">type RR struct { Text    string `xml:\",chardata\"` ID      string `xml:\"id,attr,omitempty\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` Ttl     string `xml:\"ttl\"` Type    string `xml:\"type\"` Soa     *Soa   `xml:\"soa\"` Ns      *Ns    `xml:\"ns\"` A       *A     `xml:\"a\"` Txt     *Txt   `xml:\"txt\"` Cname   *Cname `xml:\"cname\"` }<\/code><\/pre>\n<h3>A<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0432 \u0441\u0435\u0431\u0435 IPv4-\u0430\u0434\u0440\u0435\u0441 \u0410-\u0437\u0430\u043f\u0438\u0441\u0438. \u0423 \u043d\u0430\u0441, \u043f\u043e\u043a\u0430 \u0447\u0442\u043e, \u043d\u0435\u0442 IPv6, \u043d\u0435 \u0432\u043d\u0438\u043a\u0430\u043b\u0438 \u0434\u0430\u0436\u0435, \u043a\u0430\u043a \u0436\u0438\u0442\u044c \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u043e\u043c \u0432 NIC.ru, \u043d\u043e, \u0442\u0443\u0442 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e, \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 CNAME, \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442<\/p>\n<pre><code class=\"go\">type A string  func (a *A) String() string { return string(*a) }<\/code><\/pre>\n<h3>CNAME<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0432 \u0441\u0435\u0431\u0435 \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u043e\u0435 \u0438\u043c\u044f, \u0432\u0441\u0451 \u0432\u0437\u044f\u0442\u043e \u0438\u0437 API, IdnName \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0435\u043c-\u0442\u043e \u0442\u0438\u043f\u0430 &#171;\u043d\u0430\u0448-\u043b\u044e\u0431\u0438\u043c\u044b\u0439-\u0441\u0430\u0439\u0442.\u0440\u0444&#187;, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u0430\u043a Name \u0431\u0443\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0432\u0441\u0435\u043c \u0443\u0437\u043b\u0430\u043c \u0432 \u0441\u0435\u0442\u0438 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435:<\/p>\n<pre><code>xn-----6kccd6bhcmmf0dp7e6b4b.xn--p1ai<\/code><\/pre>\n<pre><code class=\"go\">type Cname struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` }<\/code><\/pre>\n<h3>Service<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0430\u044f \u0441\u0435\u0440\u0432\u0438\u0441 NIC.ru, \u0442\u0443\u0442 \u043e\u0442\u0440\u0430\u0436\u0451\u043d \u0442\u0430\u0440\u0438\u0444, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u0438 \u0442.\u043f, \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f. <\/p>\n<pre><code class=\"go\">type Service struct { Text         string `xml:\",chardata\"` Admin        string `xml:\"admin,attr\"` DomainsLimit string `xml:\"domains-limit,attr\"` DomainsNum   string `xml:\"domains-num,attr\"` Enable       string `xml:\"enable,attr\"` HasPrimary   string `xml:\"has-primary,attr\"` Name         string `xml:\"name,attr\"` Payer        string `xml:\"payer,attr\"` Tariff       string `xml:\"tariff,attr\"` RrLimit      string `xml:\"rr-limit,attr\"` RrNum        string `xml:\"rr-num,attr\"` }<\/code><\/pre>\n<h3>SOA<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 SOA-\u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<pre><code class=\"go\">type Soa struct { Text  string `xml:\",chardata\"` Mname struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` } `xml:\"mname\"` Rname struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` } `xml:\"rname\"` Serial  string `xml:\"serial\"` Refresh string `xml:\"refresh\"` Retry   string `xml:\"retry\"` Expire  string `xml:\"expire\"` Minimum string `xml:\"minimum\"` }<\/code><\/pre>\n<h3>NS<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 NS-\u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<pre><code class=\"go\">type Ns struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` }<\/code><\/pre>\n<h3>TXT<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 TXT-\u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<pre><code class=\"go\">type Ns struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` }<\/code><\/pre>\n<h3>Zone<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0437\u043e\u043d\u044b<\/p>\n<pre><code class=\"go\">type Zone struct { Text       string `xml:\",chardata\"` Admin      string `xml:\"admin,attr\"` Enable     string `xml:\"enable,attr\"` HasChanges string `xml:\"has-changes,attr\"` HasPrimary string `xml:\"has-primary,attr\"` ID         string `xml:\"id,attr\"` IdnName    string `xml:\"idn-name,attr\"` Name       string `xml:\"name,attr\"` Payer      string `xml:\"payer,attr\"` Service    string `xml:\"service,attr\"` Rr         []*RR  `xml:\"rr\"` }<\/code><\/pre>\n<h3>Revision<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0435\u0432\u0438\u0437\u0438\u0438<\/p>\n<pre><code class=\"go\">type Revision struct { Text   string `xml:\",chardata\"` Date   string `xml:\"date,attr\"` Ip     string `xml:\"ip,attr\"` Number string `xml:\"number,attr\"` }<\/code><\/pre>\n<h3>Error<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 \u043e\u0442 API<\/p>\n<pre><code class=\"go\">type Error struct { Text string `xml:\",chardata\"` Code string `xml:\"code,attr\"` }<\/code><\/pre>\n<h3>Response<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 API<\/p>\n<pre><code class=\"go\">type Response struct { XMLName xml.Name `xml:\"response\"` Text    string   `xml:\",chardata\"` Status  string   `xml:\"status\"` Errors  struct { Text  string `xml:\",chardata\"` Error *error `xml:\"error\"` } `xml:\"errors\"` Data struct { Text     string `xml:\",chardata\"` Service  []*Service Zone     []*Zone     `xml:\"zone\"` Address  []*A        `xml:\"address\"` Revision []*Revision `xml:\"revision\"` } `xml:\"data\"` }<\/code><\/pre>\n<h2>\u041a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/h2>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u043b\u0435\u0436\u0438\u0442 \u0442\u0443\u0442 <a href=\"https:\/\/github.com\/maetx777\/nic.ru-golang-client.git\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/maetx777\/nic.ru-golang-client.git<\/a>, \u0433\u043e\u0442\u043e\u0432 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e. \u0412 <a href=\"https:\/\/github.com\/maetx777\/nic.ru-golang-client\/tree\/main\/examples\" rel=\"noopener noreferrer nofollow\">examples <\/a>\u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c A\/CNAME \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0437\u043e\u043d\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b<\/h2>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0438\u0448\u0443 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043f\u0438\u0448\u043a\u043e\u0439, \u043a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439.<\/p>\n<h4>cmd\/nicru\/config.go<\/h4>\n<p>\u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<pre><code class=\"go\">package main  import api \"github.com\/maetx777\/nic.ru-golang-client\/client\"  var config = &amp;api.Config{ Credentials: &amp;api.Credentials{ OAuth2: &amp;api.OAuth2Creds{ ClientID: \"\", SecretID: \"\", }, Username: \"\", Password: \"\", }, ZoneName:       \"\", DnsServiceName: \"\", CachePath:      \"\", } <\/code><\/pre>\n<h4>cmd\/nicru\/main.go<\/h4>\n<p>\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b cmd\/nicru\/main.go:<\/p>\n<pre><code>package main  import ( \"github.com\/sirupsen\/logrus\" \"github.com\/spf13\/cobra\" )  func main() { cmd := &amp;cobra.Command{ Use:   `nicru`, Short: `\u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438 \u0432 DNS NIC.ru`, Long: `oauth2 \u043a\u043b\u044e\u0447\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u041b\u041a nic.ru - https:\/\/www.nic.ru\/manager\/oauth.cgi?step=oauth.app_register \u0438\u043c\u044f DNS-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 https:\/\/www.nic.ru\/manager\/services.cgi?step=srv.my_dns&amp;view.order_by=domain `, } \/\/\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u043b\u0430\u0433\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0430 cmd.PersistentFlags().StringVar(&amp;config.Credentials.OAuth2.ClientID, `oauth2-client-id`, ``, `oauth2 client id`) cmd.PersistentFlags().StringVar(&amp;config.Credentials.OAuth2.SecretID, `oauth2-secret-id`, ``, `oauth2 secret id`) cmd.PersistentFlags().StringVar(&amp;config.Credentials.Username, `username`, ``, `\u043b\u043e\u0433\u0438\u043d \u043e\u0442 \u041b\u041a nic.ru (******\/NIC-D)`) cmd.PersistentFlags().StringVar(&amp;config.Credentials.Password, `password`, ``, `\u043f\u0430\u0440\u043e\u043b\u044c \u043e\u0442 nic.ru`) cmd.PersistentFlags().StringVar(&amp;config.ZoneName, `zone-name`, `example.com`, `\u0438\u043c\u044f DNS-\u0437\u043e\u043d\u044b`) cmd.PersistentFlags().StringVar(&amp;config.DnsServiceName, `service-name`, `EXAMPLE`, `\u0438\u043c\u044f DNS-\u0441\u0435\u0440\u0432\u0438\u0441\u0430`) cmd.PersistentFlags().StringVar(&amp;config.CachePath, `cache-path`, `\/tmp\/.nic.ru.token`, `\u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442 API`)  cmd.AddCommand(addACmd())   \/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 add-a cmd.AddCommand(commitCmd()) \/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 add-a if err := cmd.Execute(); err != nil { logrus.Infoln(err.Error()) } } <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443, \u0432 \u043d\u0435\u0439 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u0432\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/p>\n<ul>\n<li>\n<p>addAcmd &#8212; \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0410-\u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<\/li>\n<li>\n<p>commitCmd &#8212; \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0437\u043e\u043d\u0435 <\/p>\n<\/li>\n<\/ul>\n<h4>cmd\/nicru\/config.go<\/h4>\n<p>\u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445:<\/p>\n<h4>cmd\/nicru\/add-a.go<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0410-\u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<pre><code class=\"go\">package main  import ( \"fmt\" api \"github.com\/maetx777\/nic.ru-golang-client\/client\" \"github.com\/spf13\/cobra\" )  func addACmd() *cobra.Command {  var ( names  []string \/\/\u0437\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c target string   \/\/\u0437\u0434\u0435\u0441\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f ipv4-\u0430\u0434\u0440\u0435\u0441, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u043c\u044f, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432\u044b\u0448\u0435 ttl    int      \/\/TTL \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 )  cmd := &amp;cobra.Command{ Use:   `add-a`, Short: `\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 A-\u0437\u0430\u043f\u0438\u0441\u0435\u0439`,  Run: func(cmd *cobra.Command, args []string) { \/\/\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430 client := api.NewClient(config) if response, err := client.AddA(names, target, ttl); err != nil { \/\/\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 fmt.Printf(\"Add A-record error: %s\\n\", err.Error()) return } else { \/\/\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 for _, record := range response.Data.Zone[0].Rr { fmt.Printf(\"Added A-record: %s -> %s\\n\", record.Name, record.A.String()) } } }, } \/\/\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u043b\u0430\u0433\u0438 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438\u043c\u0451\u043d \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, ipv4-\u0442\u0430\u0440\u0433\u0435\u0442\u0430 \u0438 TTL cmd.PersistentFlags().StringSliceVar(&amp;names, `names`, []string{}, `\u0438\u043c\u0435\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c`) cmd.PersistentFlags().StringVar(&amp;target, `target`, ``, `\u043a\u0443\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 1.2.3.4)`) cmd.PersistentFlags().IntVar(&amp;ttl, `ttl`, 600, `TTL \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u0437\u0430\u043f\u0438\u0441\u0435\u0439`)  return cmd }<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0437\u043e\u043d\u0435<\/p>\n<pre><code class=\"go\">package main  import ( \"fmt\" api \"github.com\/maetx777\/nic.ru-golang-client\/client\" \"github.com\/spf13\/cobra\" )  func commitCmd() *cobra.Command {  cmd := &amp;cobra.Command{ Use:   `commit`, Short: `\u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439`, Run: func(cmd *cobra.Command, args []string) { \/\/\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430 client := api.NewClient(config) \/\/\u043a\u043e\u043c\u043c\u0438\u0442\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 if _, err := client.CommitZone(); err != nil { fmt.Printf(\"Commit error: %s\\n\", err.Error()) } else { fmt.Printf(\"Zone committed\\n\") } }, }  return cmd } <\/code><\/pre>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u0443:<\/p>\n<pre><code>go build .\/cmd\/nicru<\/code><\/pre>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a \u0443\u0442\u0438\u043b\u0438\u0442\u044b<\/p>\n<pre><code class=\"bash\">$ .\/nicru --help oauth2 \u043a\u043b\u044e\u0447\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u041b\u041a nic.ru - https:\/\/www.nic.ru\/manager\/oauth.cgi?step=oauth.app_register \u0438\u043c\u044f DNS-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 https:\/\/www.nic.ru\/manager\/services.cgi?step=srv.my_dns&amp;view.order_by=domain  Usage:   nicru [command]  Available Commands:   add-a       \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 A-\u0437\u0430\u043f\u0438\u0441\u0435\u0439   commit      \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439   completion  Generate the autocompletion script for the specified shell   help        Help about any command  Flags:       --cache-path string         \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442 API (default \"\/tmp\/.nic.ru.token\")   -h, --help                      help for nicru       --oauth2-client-id string   oauth2 client id       --oauth2-secret-id string   oauth2 secret id       --password string           \u043f\u0430\u0440\u043e\u043b\u044c \u043e\u0442 nic.ru       --service-name string       \u0438\u043c\u044f DNS-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 (default \"EXAMPLE\")       --username string           \u043b\u043e\u0433\u0438\u043d \u043e\u0442 \u041b\u041a nic.ru (******\/NIC-D)       --zone-name string          \u0438\u043c\u044f DNS-\u0437\u043e\u043d\u044b (default \"example.com\")  Use \"nicru [command] --help\" for more information about a command.<\/code><\/pre>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0445\u0435\u043b\u043f \u043a\u043e\u043c\u0430\u043d\u0434\u044b add-a<\/p>\n<pre><code class=\"bash\">$ .\/nicru add-a --help \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 A-\u0437\u0430\u043f\u0438\u0441\u0435\u0439  Usage:   nicru add-a [flags]  Flags:   -h, --help            help for add-a       --names strings   \u0438\u043c\u0435\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c       --target string   \u043a\u0443\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 1.2.3.4)       --ttl int         TTL \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u0437\u0430\u043f\u0438\u0441\u0435\u0439 (default 600)  Global Flags:       --cache-path string         \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442 API (default \"\/tmp\/.nic.ru.token\")       --oauth2-client-id string   oauth2 client id       --oauth2-secret-id string   oauth2 secret id       --password string           \u043f\u0430\u0440\u043e\u043b\u044c \u043e\u0442 nic.ru       --service-name string       \u0438\u043c\u044f DNS-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 (default \"EXAMPLE\")       --username string           \u043b\u043e\u0433\u0438\u043d \u043e\u0442 \u041b\u041a nic.ru (******\/NIC-D)       --zone-name string          \u0438\u043c\u044f DNS-\u0437\u043e\u043d\u044b (default \"example.com\") <\/code><\/pre>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<pre><code class=\"bash\">$ .\/nicru add-a --oauth2-client-id *** --oauth2-secret-id *** --username ***\/NIC-D --password *** --service-name EXAMPLE --zone-name example.com --names foo123 --target 127.0.0.1 --ttl 3600 Added A-record: foo123 -> 127.0.0.1<\/code><\/pre>\n<p>\u0424\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0437\u043e\u043d\u0435<\/p>\n<pre><code class=\"go\">$ .\/nicru add-a --oauth2-client-id *** --oauth2-secret-id *** --username ***\/NIC-D --password *** --service-name EXAMPLE --zone-name example.com Zone committed<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0438\u0441\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0430, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 CNAME, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 A\/CNAME, \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435.<\/p>\n<h2>\u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u0434\u0430\u0447\u0435\u0439 oauth2-\u043a\u0440\u0435\u0434\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043b\u043e\u0433\u0438\u043d\u0430 \u0438 \u043f\u0430\u0440\u043e\u043b\u044f, \u043c\u044b \u0432 \u0441\u0432\u043e\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c vault, \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 cmd \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 ~\/.vault-token, \u0438\u0434\u0451\u0442 \u0432 \u0432\u0430\u0443\u043b\u0442, \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b \u043a\u0440\u0435\u0434\u044b, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u0444\u043e\u043b\u0442\u0430, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u043f\u043e\u0440\u0442\u044f\u043d\u043a\u0443 \u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u043d\u043e, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u0430 \u0438\u0434\u0435\u044f \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e, \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430\u043c\u0438, \u043c\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043c\u043d\u043e\u0433\u043e \u043f\u0438\u0441\u0430\u0442\u044c, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0438\u043d\u043e\u0433\u0434\u0430 &#8212; \u043d\u0435\u0442, \u0438 \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0438 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u044b.<\/p>\n<p>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0432 \u043a\u043e\u0434\u0435 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435\u0442, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043a\u0430\u0440\u043c\u0430 \u0440\u0435\u0437\u043a\u043e \u043f\u043e\u043d\u0438\u0437\u0438\u043b\u0430\u0441\u044c \u0438\u0437-\u0437\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f \u0432 <a href=\"https:\/\/habr.com\/ru\/news\/t\/664812\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0441\u0442\u0435<\/a>. \u0421 \u0443\u0447\u0451\u0442\u043e\u043c \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0445\u0443\u0434\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0440\u043c\u044b, \u0432 \u0441\u043a\u043e\u0440\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u044f \u0443\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043c\u043e\u0433\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0443\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u0442.<\/p>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0432\u044c\u0451\u043c, \u0432\u0441\u0451 \u043f\u0440\u043e\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0440\u0430\u0437\u043e\u0432\u044c\u0451\u043c \u0440\u0438\u0434\u043c\u0438 \u0438 \u0441\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437 \u0433\u0438\u0442\u0445\u0430\u0431\u0430<\/p>\n<p>\u0416\u0435\u043b\u0430\u044e \u0432\u0441\u0435\u043c \u043c\u0438\u0440\u0430 \u0438 \u0434\u043e\u0431\u0440\u0430! \u0413\u043e\u0442\u043e\u0432 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/664884\/\"> https:\/\/habr.com\/ru\/post\/664884\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0421\u043f\u0435\u0448\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u0435-\u043a\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439. Golang-\u043a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f NIC.ru API.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0435\u0441\u043d\u0430\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 nic.ru, \u0442\u0430\u043a \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438, \u0443\u0432\u0435\u0440\u0435\u043d, \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f DNS-\u0443\u0441\u043b\u0443\u0433\u0430\u043c\u0438 nic.ru, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u043d\u0435 \u0442\u0430\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043a\u0430\u043a \u043c\u044b, \u043d\u043e, \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, \u0434\u043b\u044f \u043d\u0430\u0441 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u0440\u0430\u043d\u0435\u0435 \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0430 Python, \u043d\u043e, \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0435\u0437\u0436\u0430\u0435\u043c \u043d\u0430 Go, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u043b\u043e. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0443-\u0442\u043e \u044d\u0442\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u0436\u0438\u0437\u043d\u044c \/ \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f.<\/p>\n<h2>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f python <a href=\"https:\/\/pypi.org\/project\/nic-api\/\" rel=\"noopener noreferrer nofollow\">https:\/\/pypi.org\/project\/nic-api\/<\/a><\/p>\n<p>\u0415\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0430\u0448 \u043a\u043e\u043b\u043b\u0435\u0433\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434, \u043d\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e, \u0447\u0442\u043e \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0438 \u043d\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435, \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043d\u0435\u043b\u044c\u0437\u044f \u044d\u0442\u043e \u043d\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c.<\/p>\n<p>\u0424\u043e\u0440\u043c\u0430\u0442 API \u043e\u043f\u0438\u0441\u0430\u043d <a href=\"https:\/\/www.nic.ru\/help\/upload\/file\/API_DNS-hosting.pdf\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>, \u0432\u0435\u0441\u0435\u043b\u043e\u0433\u043e \u0442\u0430\u043c \u043c\u0430\u043b\u043e, \u0432\u0441\u0451 \u043d\u0430 xml, \u043d\u043e, \u0443\u043d\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u044e\u0442.<\/p>\n<h2>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/p>\n<h3>Request<\/h3>\n<p>\u042d\u0442\u043e \u043e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<pre><code class=\"go\">type Request struct { XMLName xml.Name `xml:\"request\"` Text    string   `xml:\",chardata\"` RrList  *RrList  `xml:\"rr-list\"` }<\/code><\/pre>\n<h3>RrList<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<pre><code class=\"go\">type RrList struct { Text string `xml:\",chardata\"` Rr   []*RR  `xml:\"rr\"` }<\/code><\/pre>\n<h3>RR<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 DNS<\/p>\n<pre><code class=\"go\">type RR struct { Text    string `xml:\",chardata\"` ID      string `xml:\"id,attr,omitempty\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` Ttl     string `xml:\"ttl\"` Type    string `xml:\"type\"` Soa     *Soa   `xml:\"soa\"` Ns      *Ns    `xml:\"ns\"` A       *A     `xml:\"a\"` Txt     *Txt   `xml:\"txt\"` Cname   *Cname `xml:\"cname\"` }<\/code><\/pre>\n<h3>A<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0432 \u0441\u0435\u0431\u0435 IPv4-\u0430\u0434\u0440\u0435\u0441 \u0410-\u0437\u0430\u043f\u0438\u0441\u0438. \u0423 \u043d\u0430\u0441, \u043f\u043e\u043a\u0430 \u0447\u0442\u043e, \u043d\u0435\u0442 IPv6, \u043d\u0435 \u0432\u043d\u0438\u043a\u0430\u043b\u0438 \u0434\u0430\u0436\u0435, \u043a\u0430\u043a \u0436\u0438\u0442\u044c \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u043e\u043c \u0432 NIC.ru, \u043d\u043e, \u0442\u0443\u0442 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e, \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 CNAME, \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442<\/p>\n<pre><code class=\"go\">type A string  func (a *A) String() string { return string(*a) }<\/code><\/pre>\n<h3>CNAME<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0432 \u0441\u0435\u0431\u0435 \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u043e\u0435 \u0438\u043c\u044f, \u0432\u0441\u0451 \u0432\u0437\u044f\u0442\u043e \u0438\u0437 API, IdnName \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0435\u043c-\u0442\u043e \u0442\u0438\u043f\u0430 &#171;\u043d\u0430\u0448-\u043b\u044e\u0431\u0438\u043c\u044b\u0439-\u0441\u0430\u0439\u0442.\u0440\u0444&#187;, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u0430\u043a Name \u0431\u0443\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0432\u0441\u0435\u043c \u0443\u0437\u043b\u0430\u043c \u0432 \u0441\u0435\u0442\u0438 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435:<\/p>\n<pre><code>xn-----6kccd6bhcmmf0dp7e6b4b.xn--p1ai<\/code><\/pre>\n<pre><code class=\"go\">type Cname struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` }<\/code><\/pre>\n<h3>Service<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0430\u044f \u0441\u0435\u0440\u0432\u0438\u0441 NIC.ru, \u0442\u0443\u0442 \u043e\u0442\u0440\u0430\u0436\u0451\u043d \u0442\u0430\u0440\u0438\u0444, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u0438 \u0442.\u043f, \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f. <\/p>\n<pre><code class=\"go\">type Service struct { Text         string `xml:\",chardata\"` Admin        string `xml:\"admin,attr\"` DomainsLimit string `xml:\"domains-limit,attr\"` DomainsNum   string `xml:\"domains-num,attr\"` Enable       string `xml:\"enable,attr\"` HasPrimary   string `xml:\"has-primary,attr\"` Name         string `xml:\"name,attr\"` Payer        string `xml:\"payer,attr\"` Tariff       string `xml:\"tariff,attr\"` RrLimit      string `xml:\"rr-limit,attr\"` RrNum        string `xml:\"rr-num,attr\"` }<\/code><\/pre>\n<h3>SOA<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 SOA-\u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<pre><code class=\"go\">type Soa struct { Text  string `xml:\",chardata\"` Mname struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` } `xml:\"mname\"` Rname struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` } `xml:\"rname\"` Serial  string `xml:\"serial\"` Refresh string `xml:\"refresh\"` Retry   string `xml:\"retry\"` Expire  string `xml:\"expire\"` Minimum string `xml:\"minimum\"` }<\/code><\/pre>\n<h3>NS<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 NS-\u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<pre><code class=\"go\">type Ns struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` }<\/code><\/pre>\n<h3>TXT<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 TXT-\u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<pre><code class=\"go\">type Ns struct { Text    string `xml:\",chardata\"` Name    string `xml:\"name\"` IdnName string `xml:\"idn-name,omitempty\"` }<\/code><\/pre>\n<h3>Zone<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0437\u043e\u043d\u044b<\/p>\n<pre><code class=\"go\">type Zone struct { Text       string `xml:\",chardata\"` Admin      string `xml:\"admin,attr\"` Enable     string `xml:\"enable,attr\"` HasChanges string `xml:\"has-changes,attr\"` HasPrimary string `xml:\"has-primary,attr\"` ID         string `xml:\"id,attr\"` IdnName    string `xml:\"idn-name,attr\"` Name       string `xml:\"name,attr\"` Payer      string `xml:\"payer,attr\"` Service    string `xml:\"service,attr\"` Rr         []*RR  `xml:\"rr\"` }<\/code><\/pre>\n<h3>Revision<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0435\u0432\u0438\u0437\u0438\u0438<\/p>\n<pre><code class=\"go\">type Revision struct { Text   string `xml:\",chardata\"` Date   string `xml:\"date,attr\"` Ip     string `xml:\"ip,attr\"` Number string `xml:\"number,attr\"` }<\/code><\/pre>\n<h3>Error<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 \u043e\u0442 API<\/p>\n<pre><code class=\"go\">type Error struct { Text string `xml:\",chardata\"` Code string `xml:\"code,attr\"` }<\/code><\/pre>\n<h3>Response<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 API<\/p>\n<pre><code class=\"go\">type Response struct { XMLName xml.Name `xml:\"response\"` Text    string   `xml:\",chardata\"` Status  string   `xml:\"status\"` Errors  struct { Text  string `xml:\",chardata\"` Error *error `xml:\"error\"` } `xml:\"errors\"` Data struct { Text     string `xml:\",chardata\"` Service  []*Service Zone     []*Zone     `xml:\"zone\"` Address  []*A        `xml:\"address\"` Revision []*Revision `xml:\"revision\"` } `xml:\"data\"` }<\/code><\/pre>\n<h2>\u041a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/h2>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u043b\u0435\u0436\u0438\u0442 \u0442\u0443\u0442 <a href=\"https:\/\/github.com\/maetx777\/nic.ru-golang-client.git\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/maetx777\/nic.ru-golang-client.git<\/a>, \u0433\u043e\u0442\u043e\u0432 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e. \u0412 <a href=\"https:\/\/github.com\/maetx777\/nic.ru-golang-client\/tree\/main\/examples\" rel=\"noopener noreferrer nofollow\">examples <\/a>\u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c A\/CNAME \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0437\u043e\u043d\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b<\/h2>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0438\u0448\u0443 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043f\u0438\u0448\u043a\u043e\u0439, \u043a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439.<\/p>\n<h4>cmd\/nicru\/config.go<\/h4>\n<p>\u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<pre><code class=\"go\">package main  import api \"github.com\/maetx777\/nic.ru-golang-client\/client\"  var config = &amp;api.Config{ Credentials: &amp;api.Credentials{ OAuth2: &amp;api.OAuth2Creds{ ClientID: \"\", SecretID: \"\", }, Username: \"\", Password: \"\", }, ZoneName:       \"\", DnsServiceName: \"\", CachePath:      \"\", } <\/code><\/pre>\n<h4>cmd\/nicru\/main.go<\/h4>\n<p>\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b cmd\/nicru\/main.go:<\/p>\n<pre><code>package main  import ( \"github.com\/sirupsen\/logrus\" \"github.com\/spf13\/cobra\" )  func main() { cmd := &amp;cobra.Command{ Use:   `nicru`, Short: `\u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438 \u0432 DNS NIC.ru`, Long: `oauth2 \u043a\u043b\u044e\u0447\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u041b\u041a nic.ru - https:\/\/www.nic.ru\/manager\/oauth.cgi?step=oauth.app_register \u0438\u043c\u044f DNS-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 https:\/\/www.nic.ru\/manager\/services.cgi?step=srv.my_dns&amp;view.order_by=domain `, } \/\/\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u043b\u0430\u0433\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0430 cmd.PersistentFlags().StringVar(&amp;config.Credentials.OAuth2.ClientID, `oauth2-client-id`, ``, `oauth2 client id`) cmd.PersistentFlags().StringVar(&amp;config.Credentials.OAuth2.SecretID, `oauth2-secret-id`, ``, `oauth2 secret id`) cmd.PersistentFlags().StringVar(&amp;config.Credentials.Username, `username`, ``, `\u043b\u043e\u0433\u0438\u043d \u043e\u0442 \u041b\u041a nic.ru (******\/NIC-D)`) cmd.PersistentFlags().StringVar(&amp;config.Credentials.Password, `password`, ``, `\u043f\u0430\u0440\u043e\u043b\u044c \u043e\u0442 nic.ru`) cmd.PersistentFlags().StringVar(&amp;config.ZoneName, `zone-name`, `example.com`, `\u0438\u043c\u044f DNS-\u0437\u043e\u043d\u044b`) cmd.PersistentFlags().StringVar(&amp;config.DnsServiceName, `service-name`, `EXAMPLE`, `\u0438\u043c\u044f DNS-\u0441\u0435\u0440\u0432\u0438\u0441\u0430`) cmd.PersistentFlags().StringVar(&amp;config.CachePath, `cache-path`, `\/tmp\/.nic.ru.token`, `\u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442 API`)  cmd.AddCommand(addACmd())   \/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 add-a cmd.AddCommand(commitCmd()) \/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 add-a if err := cmd.Execute(); err != nil { logrus.Infoln(err.Error()) } } <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443, \u0432 \u043d\u0435\u0439 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u0432\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/p>\n<ul>\n<li>\n<p>addAcmd &#8212; \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0410-\u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<\/li>\n<li>\n<p>commitCmd &#8212; \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0437\u043e\u043d\u0435 <\/p>\n<\/li>\n<\/ul>\n<h4>cmd\/nicru\/config.go<\/h4>\n<p>\u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445:<\/p>\n<h4>cmd\/nicru\/add-a.go<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0410-\u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<pre><code class=\"go\">package main  import ( \"fmt\" api \"github.com\/maetx777\/nic.ru-golang-client\/client\" \"github.com\/spf13\/cobra\" )  func addACmd() *cobra.Command {  var ( names  []string \/\/\u0437\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c target string   \/\/\u0437\u0434\u0435\u0441\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f ipv4-\u0430\u0434\u0440\u0435\u0441, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u043c\u044f, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432\u044b\u0448\u0435 ttl    int      \/\/TTL \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 )  cmd := &amp;cobra.Command{ Use:   `add-a`, Short: `\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 A-\u0437\u0430\u043f\u0438\u0441\u0435\u0439`,  Run: func(cmd *cobra.Command, args []string) { \/\/\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430 client := api.NewClient(config) if response, err := client.AddA(names, target, ttl); err != nil { \/\/\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 fmt.Printf(\"Add A-record error: %s\\n\", err.Error()) return } else { \/\/\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 for _, record := range response.Data.Zone[0].Rr { fmt.Printf(\"Added A-record: %s -> %s\\n\", record.Name, record.A.String()) } } }, } \/\/\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u043b\u0430\u0433\u0438 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438\u043c\u0451\u043d \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, ipv4-\u0442\u0430\u0440\u0433\u0435\u0442\u0430 \u0438 TTL cmd.PersistentFlags().StringSliceVar(&amp;names, `names`, []string{}, `\u0438\u043c\u0435\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c`) cmd.PersistentFlags().StringVar(&amp;target, `target`, ``, `\u043a\u0443\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 1.2.3.4)`) cmd.PersistentFlags().IntVar(&amp;ttl, `ttl`, 600, `TTL \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u0437\u0430\u043f\u0438\u0441\u0435\u0439`)  return cmd }<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0437\u043e\u043d\u0435<\/p>\n<pre><code class=\"go\">package main  import ( \"fmt\" api \"github.com\/maetx777\/nic.ru-golang-client\/client\" \"github.com\/spf13\/cobra\" )  func commitCmd() *cobra.Command {  cmd := &amp;cobra.Command{ Use:   `commit`, Short: `\u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439`, Run: func(cmd *cobra.Command, args []string) { \/\/\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430 client := api.NewClient(config) \/\/\u043a\u043e\u043c\u043c\u0438\u0442\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 if _, err := client.CommitZone(); err != nil { fmt.Printf(\"Commit error: %s\\n\", err.Error()) } else { fmt.Printf(\"Zone committed\\n\") } }, }  return cmd } <\/code><\/pre>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u0443:<\/p>\n<pre><code>go build .\/cmd\/nicru<\/code><\/pre>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a \u0443\u0442\u0438\u043b\u0438\u0442\u044b<\/p>\n<pre><code class=\"bash\">$ .\/nicru --help oauth2 \u043a\u043b\u044e\u0447\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u041b\u041a nic.ru - https:\/\/www.nic.ru\/manager\/oauth.cgi?step=oauth.app_register \u0438\u043c\u044f DNS-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 https:\/\/www.nic.ru\/manager\/services.cgi?step=srv.my_dns&amp;view.order_by=domain  Usage:   nicru [command]  Available Commands:   add-a       \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 A-\u0437\u0430\u043f\u0438\u0441\u0435\u0439   commit      \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439   completion  Generate the autocompletion script for the specified shell   help        Help about any command  Flags:       --cache-path string         \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442 API (default \"\/tmp\/.nic.ru.token\")   -h, --help                      help for nicru       --oauth2-client-id string   oauth2 client id       --oauth2-secret-id string   oauth2 secret id<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-332923","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=332923"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332923\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}