func (api *GSLBAPI) findOrCreateBy(gslbName string) (*sacloud.GSLB, error) { req := &sacloud.Request{} req.AddFilter("Name", gslbName) res, err := api.Find() if err != nil { return nil, err } //すでに登録されている場合 var gslbItem *sacloud.GSLB if res.Count > 0 { gslbItem = &res.CommonServiceGSLBItems[0] } else { gslbItem = sacloud.CreateNewGSLB(gslbName) } return gslbItem, nil }
func (api *GSLBAPI) New(name string) *sacloud.GSLB { return sacloud.CreateNewGSLB(name) }