Пример #1
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() != 2 {
		flag.Usage()
		os.Exit(-1)
	}
	imsi := flag.Arg(0)
	speed := flag.Arg(1)

	c, err := goracom.NewClient(email, password)
	errToExit(err)
	s := c.NewSubscriber()

	if sub, err := s.UpdateSpeedClass(imsi, speed); err == nil {
		printSubscriber(*sub)
	} else {
		errToExit(err)
	}
}
Пример #2
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg()%2 == 0 {
		flag.Usage()
		os.Exit(-1)
	}
	imsi := flag.Arg(0)
	tags := make([]map[string]string, (flag.NArg()-1)/2)
	idx := 0
	for i := 1; i < flag.NArg(); i += 2 {
		k := flag.Arg(i)
		v := flag.Arg(i + 1)
		tag := map[string]string{"tagName": k, "tagValue": v}
		tags[idx] = tag
		idx++
	}
	fmt.Println(tags)

	c, err := goracom.NewClient(email, password)
	errToExit(err)
	s := c.NewSubscriber()
	sub, err := s.Tags(imsi, tags)
	errToExit(err)
	printSubscriber(*sub)
}
Пример #3
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() != 2 {
		flag.Usage()
		os.Exit(-1)
	}
	imsi := flag.Arg(0)
	tm, err := strconv.ParseInt(flag.Arg(1), 10, 64)
	if err != nil {
		fmt.Printf("%s\n\n", err.Error())
		flag.Usage()
		os.Exit(-1)
	}

	c, err := goracom.NewClient(email, password)
	errToExit(err)
	s := c.NewSubscriber()
	if tm == 0 {
		sub, err := s.UnsetExpiryTime(imsi)
		errToExit(err)
		printSubscriber(*sub)
	} else {
		sub, err := s.SetExpiryTime(imsi, tm)
		errToExit(err)
		printSubscriber(*sub)
	}
}
Пример #4
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() != 2 {
		flag.Usage()
		os.Exit(-1)
	}
	imsi = flag.Arg(0)
	active = flag.Arg(1)

	c, err := goracom.NewClient(email, password)
	errToPanic(err)

	s := c.NewSubscriber()
	if active == "active" {
		sub, err := s.Activate(imsi)
		errToPanic(err)
		printSubscriber(*sub)
	} else {
		sub, err := s.Deactivate(imsi)
		errToPanic(err)
		printSubscriber(*sub)
	}
}
Пример #5
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() != 2 {
		flag.Usage()
		os.Exit(-1)
	}
	imsi := flag.Arg(0)
	protection := flag.Arg(1)

	c, err := goracom.NewClient(email, password)
	errToExit(err)
	s := c.NewSubscriber()
	if protection == "false" {
		sub, err := s.EnableTerminate(imsi)
		errToExit(err)
		printSubscriber(*sub)
	} else {
		sub, err := s.DisableTerminate(imsi)
		errToExit(err)
		printSubscriber(*sub)
	}
}
Пример #6
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() < 4 {
		flag.Usage()
		os.Exit(-1)
	}
	mode := flag.Arg(0)
	id := flag.Arg(1)
	from, err := strconv.ParseInt(flag.Arg(2), 10, 64)
	errToExit(err)
	to, err := strconv.ParseInt(flag.Arg(3), 10, 64)
	errToExit(err)

	c, err := goracom.NewClient(email, password)
	errToExit(err)

	s := c.NewStats()
	url, err := s.ExportReport(mode, id, from, to)
	errToExit(err)
	fmt.Println(url)
}
Пример #7
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		flag.Usage()
		os.Exit(-1)
	}

	if 0 < flag.NArg() {
		imsi = flag.Arg(0)
	}

	c, err := goracom.NewClient(email, password)
	errToPanic(err)

	s := c.NewSubscriber()
	if imsi != "" {
		sub, err := s.Sim(imsi)
		errToPanic(err)
		printSubscriber(*sub)
	} else {
		ss, err := s.FindAll()
		errToPanic(err)

		fmt.Println("===============================")
		for _, sub := range *ss {
			printSubscriber(sub)
			fmt.Println("===============================")
		}
	}
}
Пример #8
0
func main() {
	flag.Parse()

	if flag.NArg() < 2 {
		flag.Usage()
		return
	}

	email := flag.Arg(0)
	password := flag.Arg(1)

	c, err := goracom.NewClient(email, password)
	errToPanic(err)

	subscriber := c.NewSubscriber()
	s, err := subscriber.SearchAll()
	errToPanic(err)

	fmt.Println("===============================")
	for _, sub := range *s {
		fmt.Println("IMSI=", sub.IMSI())
		fmt.Println("SpeedClass=", sub.SpeedClass())
		fmt.Println("GroupID=", sub.GroupId())
		fmt.Println("OperatorID=", sub.OperatorId())
		fmt.Println("ModuleType=", sub.ModuleType())
		fmt.Println("APN=", sub.APN())
		fmt.Println("===============================")
	}
}
Пример #9
0
// listContainers handles and reply to http requests having the path "/containers"
func listContainers(w http.ResponseWriter, r *http.Request) {

	// answer right away to avoid dead locks in LUA
	io.WriteString(w, "OK")

	email := os.Getenv("SORACOM_EMAIL")
	pass := os.Getenv("SORACOM_PASSWORD")
	c, err := goracom.NewClient(email, pass)
	if err != nil {
		logrus.Println(err.Error())
		return
	}
	s := c.NewSubscriber()
	ss, _ := s.FindAll()
	if err != nil {
		logrus.Println(err.Error())
		return
	}
	logrus.Println(ss)
	for _, sim := range *ss {
		go func() {
			data := url.Values{
				"action":    {"containerInfos"},
				"id":        {sim.IMSI},
				"name":      {sim.Tags["name"]},
				"imageRepo": {sim.SpeedClass},
				"imageTag":  {sim.ModuleType},
				"running":   {strconv.FormatBool(sim.Status == "active")},
			}

			CuberiteServerRequest(data)
		}()
	}
}
Пример #10
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() == 0 {
		flag.Usage()
		os.Exit(-1)
	}

	c, err := goracom.NewClient(email, password)
	errToExit(err)
	o := c.NewOperators()
	id := flag.Arg(0)

	if sub, err := o.FindId(id); err == nil {
		printOperators(*sub)
	} else {
		errToExit(err)
	}
}
Пример #11
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() < 5 {
		flag.Usage()
		os.Exit(-1)
	}
	mode := flag.Arg(0)
	imsi := flag.Arg(1)
	from, err := strconv.ParseInt(flag.Arg(2), 10, 64)
	errToExit(err)
	to, err := strconv.ParseInt(flag.Arg(3), 10, 64)
	errToExit(err)
	period := flag.Arg(4)

	c, err := goracom.NewClient(email, password)
	errToExit(err)

	s := c.NewStats()
	if mode == "air" {
		report, err := s.AirReport(imsi, from, to, period)
		errToExit(err)
		printAirReports(*report)
	} else {
		report, err := s.BeamReport(imsi, from, to, period)
		errToExit(err)
		printBeamReports(*report)
	}
}
Пример #12
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() != 2 {
		flag.Usage()
		os.Exit(-1)
	}
	imsi := flag.Arg(0)
	tag := flag.Arg(1)

	c, err := goracom.NewClient(email, password)
	errToExit(err)
	s := c.NewSubscriber()
	err = s.DeleteTag(imsi, tag)
	errToExit(err)
	fmt.Println("Success!")
}