Class: Opc::OpcOrgEdit

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/opc_org_edit.rb

Instance Method Summary collapse

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/chef/knife/opc_org_edit.rb', line 25

def run
  org_name = @name_args[0]

  if org_name.nil?
    show_usage
    ui.fatal("You must specify an organization name")
    exit 1
  end

  include Chef::Mixin::RootRestv0

  original_org = root_rest.get("organizations/#{org_name}")
  edited_org = edit_data(original_org)

  if original_org == edited_org
    ui.msg("Organization unchanged, not saving.")
    exit
  end

  ui.msg edited_org
  root_rest.put("organizations/#{org_name}", edited_org)
  ui.msg("Saved #{org_name}.")
end