MCPcopy Create free account
hub / github.com/auth0/auth0-cli / createOrganizationCmd

Function createOrganizationCmd

internal/cli/organizations.go:301–383  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

299}
300
301func createOrganizationCmd(cli *cli) *cobra.Command {
302 var inputs struct {
303 Name string
304 DisplayName string
305 LogoURL string
306 AccentColor string
307 BackgroundColor string
308 Metadata map[string]string
309 }
310
311 cmd := &cobra.Command{
312 Use: "create",
313 Args: cobra.NoArgs,
314 Short: "Create a new organization",
315 Long: "Create a new organization.\n\n" +
316 "To create interactively, use `auth0 orgs create` with no arguments.\n\n" +
317 "To create non-interactively, supply the name and other information through the flags.",
318 Example: ` auth0 orgs create
319 auth0 orgs create --name myorganization
320 auth0 orgs create -n myorganization --display "My Organization"
321 auth0 orgs create -n myorganization -d "My Organization" -l "https://example.com/logo.png" -a "#635DFF" -b "#2A2E35"
322 auth0 orgs create -n myorganization -d "My Organization" -m "KEY=value" -m "OTHER_KEY=other_value"`,
323 RunE: func(cmd *cobra.Command, args []string) error {
324 if err := organizationName.Ask(cmd, &inputs.Name, nil); err != nil {
325 return err
326 }
327
328 if err := organizationDisplay.Ask(cmd, &inputs.DisplayName, nil); err != nil {
329 return err
330 }
331
332 newOrg := &management.Organization{
333 Name: &inputs.Name,
334 DisplayName: &inputs.DisplayName,
335 }
336
337 if inputs.Metadata != nil {
338 newOrg.Metadata = &inputs.Metadata
339 }
340
341 branding := management.OrganizationBranding{}
342 if inputs.LogoURL != "" {
343 branding.LogoURL = &inputs.LogoURL
344 }
345
346 colors := make(map[string]string)
347 if inputs.AccentColor != "" {
348 colors[apiOrganizationColorPrimary] = inputs.AccentColor
349 }
350 if inputs.BackgroundColor != "" {
351 colors[apiOrganizationColorPageBackground] = inputs.BackgroundColor
352 }
353 if len(colors) > 0 {
354 branding.Colors = &colors
355 }
356
357 if branding.String() != "{}" {
358 newOrg.Branding = &branding

Callers 1

organizationsCmdFunction · 0.85

Calls 7

WaitingFunction · 0.92
ErrorfMethod · 0.80
OrganizationCreateMethod · 0.80
RegisterStringMethod · 0.80
RegisterStringMapMethod · 0.80
CreateMethod · 0.65
AskMethod · 0.45

Tested by

no test coverage detected