func (api *DNSAPI) findOrCreateBy(zoneName string) (*sacloud.DNS, error) { res, err := api.WithNameLike(zoneName).Limit(1).Find() if err != nil { return nil, err } //すでに登録されている場合 var dnsItem *sacloud.DNS if res.Count > 0 { dnsItem = &res.CommonServiceDNSItems[0] } else { dnsItem = sacloud.CreateNewDNS(zoneName) } return dnsItem, nil }
func (api *DNSAPI) New(zoneName string) *sacloud.DNS { return sacloud.CreateNewDNS(zoneName) }