| 1 |
/* |
| 2 |
Copyright (c) 2019 VMware, Inc. All Rights Reserved. |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package group |
| 18 |
|
| 19 |
import ( |
| 20 |
"context" |
| 21 |
"flag" |
| 22 |
|
| 23 |
"github.com/vmware/govmomi/govc/cli" |
| 24 |
"github.com/vmware/govmomi/govc/flags" |
| 25 |
"github.com/vmware/govmomi/govc/sso" |
| 26 |
"github.com/vmware/govmomi/ssoadmin" |
| 27 |
"github.com/vmware/govmomi/ssoadmin/types" |
| 28 |
) |
| 29 |
|
| 30 |
type create struct { |
| 31 |
*flags.ClientFlag |
| 32 |
|
| 33 |
types.AdminGroupDetails |
| 34 |
} |
| 35 |
|
| 36 |
func (cmd *create) Usage() string { |
| 37 |
return "NAME" |
| 38 |
} |
| 39 |
|
| 40 |
func (cmd *create) Register(ctx context.Context, f *flag.FlagSet) { |
| 41 |
cmd.ClientFlag, ctx = flags.NewClientFlag(ctx) |
| 42 |
cmd.ClientFlag.Register(ctx, f) |
| 43 |
|
| 44 |
f.StringVar(&cmd.AdminGroupDetails.Description, "d", "", "Group description") |
| 45 |
} |
| 46 |
|
| 47 |
func init() { |
| 48 |
cli.Register("sso.group.create", &create{}) |
| 49 |
} |
| 50 |
|
| 51 |
func (cmd *create) Description() string { |
| 52 |
return `Create SSO group. |
| 53 |
|
| 54 |
Examples: |
| 55 |
govc sso.group.create NAME` |
| 56 |
} |
| 57 |
|
| 58 |
func (cmd *create) Run(ctx context.Context, f *flag.FlagSet) error { |
| 59 |
if f.NArg() != 1 { |
| 60 |
return flag.ErrHelp |
| 61 |
} |
| 62 |
|
| 63 |
return sso.WithClient(ctx, cmd.ClientFlag, func(c *ssoadmin.Client) error { |
| 64 |
return c.CreateGroup(ctx, f.Arg(0), cmd.AdminGroupDetails) |
| 65 |
}) |
| 66 |
} |