implement mdmctl dep commands (#161)

adds subcommands for endpoints implemented in #160
   mdmctl get dep-devices
   mdmctl get dep-account
   mdmctl get dep-profiles
   mdmctl apply dep-profiles
  
Closes #154
This commit is contained in:
Victor Vrantchan
2017-05-27 23:22:32 -04:00
committed by GitHub
parent c63d0fc152
commit e0efa31d28
10 changed files with 231 additions and 321 deletions

View File

@@ -0,0 +1,47 @@
package main
import (
"context"
"flag"
"fmt"
"os"
"strings"
"text/tabwriter"
)
type depProfilesTableOutput struct{ w *tabwriter.Writer }
func (out *depProfilesTableOutput) BasicHeader() {
fmt.Fprintf(out.w, "Name\tMandatory\tRemovable\tAwaitConfigured\tSkippedItems\n")
}
func (out *depProfilesTableOutput) BasicFooter() {
out.w.Flush()
}
func (cmd *getCommand) getDEPProfiles(args []string) error {
flagset := flag.NewFlagSet("dep-profiles", flag.ExitOnError)
flUUID := flagset.String("uuid", "", "DEP Profile UUID")
flagset.Usage = usageFor(flagset, "mdmctl get dep-profiles [flags]")
if err := flagset.Parse(args); err != nil {
return err
}
w := tabwriter.NewWriter(os.Stderr, 0, 4, 2, ' ', 0)
out := &depProfilesTableOutput{w}
out.BasicHeader()
defer out.BasicFooter()
ctx := context.Background()
resp, err := cmd.list.GetDEPProfile(ctx, *flUUID)
if err != nil {
return err
}
fmt.Fprintf(out.w, "%s\t%v\t%v\t%v\t%s\n",
resp.ProfileName,
resp.IsMandatory,
resp.IsMDMRemovable,
resp.AwaitDeviceConfigured,
strings.Join(resp.SkipSetupItems, ","),
)
return nil
}