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

Function updateOrganizationCmd

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

Source from the content-addressed store, hash-verified

383}
384
385func updateOrganizationCmd(cli *cli) *cobra.Command {
386 var inputs struct {
387 ID string
388 DisplayName string
389 LogoURL string
390 AccentColor string
391 BackgroundColor string
392 Metadata map[string]string
393 }
394
395 cmd := &cobra.Command{
396 Use: "update",
397 Args: cobra.MaximumNArgs(1),
398 Short: "Update an organization",
399 Long: "Update an organization.\n\n" +
400 "To update interactively, use `auth0 orgs update` with no arguments.\n\n" +
401 "To update non-interactively, supply the organization id and " +
402 "other information through the flags.",
403 Example: ` auth0 orgs update <org-id>
404 auth0 orgs update <org-id> --display "My Organization"
405 auth0 orgs update <org-id> -d "My Organization" -l "https://example.com/logo.png" -a "#635DFF" -b "#2A2E35"
406 auth0 orgs update <org-id> -d "My Organization" -m "KEY=value" -m "OTHER_KEY=other_value"`,
407 RunE: func(cmd *cobra.Command, args []string) error {
408 if len(args) > 0 {
409 inputs.ID = args[0]
410 } else {
411 if err := organizationID.Pick(cmd, &inputs.ID, cli.organizationPickerOptions); err != nil {
412 return err
413 }
414 }
415
416 var oldOrg *management.Organization
417 err := ansi.Waiting(func() (err error) {
418 oldOrg, err = cli.api.Organization.Read(cmd.Context(), inputs.ID)
419 return err
420 })
421 if err != nil {
422 return fmt.Errorf("failed to read organization with ID %q: %w", inputs.ID, err)
423 }
424
425 if err := organizationDisplay.AskU(cmd, &inputs.DisplayName, oldOrg.DisplayName); err != nil {
426 return err
427 }
428
429 if inputs.DisplayName == "" {
430 inputs.DisplayName = oldOrg.GetDisplayName()
431 }
432
433 newOrg := &management.Organization{
434 DisplayName: &inputs.DisplayName,
435 }
436
437 isLogoURLSet := len(inputs.LogoURL) > 0
438 isAccentColorSet := len(inputs.AccentColor) > 0
439 isBackgroundColorSet := len(inputs.BackgroundColor) > 0
440 currentHasBranding := oldOrg.Branding != nil
441 currentHasColors := currentHasBranding && oldOrg.Branding.Colors != nil
442 needToAddColors := isAccentColorSet || isBackgroundColorSet || currentHasColors

Callers 1

organizationsCmdFunction · 0.85

Calls 9

WaitingFunction · 0.92
ErrorfMethod · 0.80
AskUMethod · 0.80
OrganizationUpdateMethod · 0.80
RegisterStringUMethod · 0.80
RegisterStringMapUMethod · 0.80
ReadMethod · 0.65
UpdateMethod · 0.65
PickMethod · 0.45

Tested by

no test coverage detected