Example #1
0
func activityCreate(c *cli.Context) error {
	ctx := context.Background()
	client, err := doaramacli.NewAuthenticatedDoaramaClient(c)
	if err != nil {
		return err
	}
	defer client.Close()
	activityType, err := doarama.DefaultActivityTypes.Find(doaramacli.ActivityType(c))
	if err != nil {
		return err
	}
	activityInfo := &doarama.ActivityInfo{
		TypeID: activityType.ID,
	}
	cache, err := newCache(c, client)
	if err != nil {
		return err
	}
	defer cache.Close()
	for _, arg := range c.Args() {
		a, err := activityCreateOne(ctx, cache, arg, activityInfo)
		if err != nil {
			log.Print(err)
			continue
		}
		fmt.Printf("ActivityId: %d\n", a.ID)
	}
	return nil
}
Example #2
0
func create(c *cli.Context) error {
	ctx := context.Background()
	client, err := doaramacli.NewAuthenticatedDoaramaClient(c)
	if err != nil {
		return err
	}
	defer client.Close()
	activityType, err := doarama.DefaultActivityTypes.Find(doaramacli.ActivityType(c))
	if err != nil {
		return err
	}
	activityInfo := &doarama.ActivityInfo{
		TypeID: activityType.ID,
	}
	cache, err := newCache(c, client)
	if err != nil {
		return err
	}
	defer cache.Close()
	var as []*doarama.Activity
	for _, arg := range c.Args() {
		var a *doarama.Activity
		a, err = activityCreateOne(ctx, cache, arg, activityInfo)
		if err != nil {
			break
		}
		fmt.Printf("ActivityId: %d\n", a.ID)
		as = append(as, a)
	}
	if err != nil {
		for _, a := range as {
			a.Delete(ctx)
		}
		return err
	}
	if len(as) == 0 {
		return errors.New("no activities specified")
	}
	v, err := client.CreateVisualisation(ctx, as)
	if err != nil {
		return err
	}
	fmt.Printf("VisualisationKey: %s\n", v.Key)
	vuo := doaramacli.NewVisualisationURLOptions(c)
	fmt.Printf("VisualisationURL: %s\n", v.URL(vuo))
	return nil
}
Example #3
0
func activityDelete(c *cli.Context) error {
	ctx := context.Background()
	client, err := doaramacli.NewAuthenticatedDoaramaClient(c)
	if err != nil {
		return err
	}
	defer client.Close()
	var ids []int
	for _, arg := range c.Args() {
		id64, err := strconv.ParseInt(arg, 10, 0)
		if err != nil {
			return err
		}
		ids = append(ids, int(id64))
	}
	for _, id := range ids {
		a := client.Activity(id)
		if err := a.Delete(ctx); err != nil {
			log.Print(err)
			continue
		}
	}
	return nil
}
Example #4
0
func visualisationCreate(c *cli.Context) error {
	ctx := context.Background()
	client, err := doaramacli.NewAuthenticatedDoaramaClient(c)
	if err != nil {
		return err
	}
	defer client.Close()
	var as []*doarama.Activity
	for _, arg := range c.Args() {
		var id64 int64
		id64, err = strconv.ParseInt(arg, 10, 0)
		if err != nil {
			return err
		}
		a := client.Activity(int(id64))
		as = append(as, a)
	}
	v, err := client.CreateVisualisation(ctx, as)
	if err != nil {
		return err
	}
	fmt.Printf("VisualisationKey: %s\n", v.Key)
	return nil
}