mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-14 17:41:43 +08:00
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:
47
cmd/mdmctl/get_dep_profiles.go
Normal file
47
cmd/mdmctl/get_dep_profiles.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user