Class: AcquiaToolbelt::CLI::SVN

Inherits:
Thor
  • Object
show all
Defined in:
lib/acquia_toolbelt/cli/svn.rb

Constant Summary

Constants inherited from Thor

Thor::AmbiguousTaskError, Thor::DynamicTask, Thor::HELP_MAPPINGS, Thor::HiddenTask, Thor::THOR_RESERVED_WORDS, Thor::UndefinedTaskError, Thor::VERSION

Instance Attribute Summary

Attributes included from Thor::Base

#args, #options, #parent_options

Instance Method Summary collapse

Methods inherited from Thor

check_unknown_options!, check_unknown_options?, command_help, default_command, desc, #help, help, long_desc, map, method_option, method_options, package_name, printable_commands, register, stop_on_unknown_option!, stop_on_unknown_option?, subcommand, subcommands

Methods included from Thor::Base

included, #initialize, register_klass_file, shell, shell=, subclass_files, subclasses

Instance Method Details

#addObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/acquia_toolbelt/cli/svn.rb', line 31

def add
  if options[:subscription]
    subscription = options[:subscription]
  else
    subscription = AcquiaToolbelt::CLI::API.default_subscription
  end

  username = options[:username]
  password = options[:password]

  add_svn_user = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/svnusers/#{username}", 'POST', :password => "#{password}"
  if add_svn_user['id']
    ui.success "User '#{username}' has been successfully created."
  else
    ui.fail AcquiaToolbelt::CLI::API.display_error(add_svn_user)
  end
end

#deleteObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/acquia_toolbelt/cli/svn.rb', line 55

def delete
  if options[:subscription]
    subscription = options[:subscription]
  else
    subscription = AcquiaToolbelt::CLI::API.default_subscription
  end

  userid = options[:id]

  svn_user_removal = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/svnusers/#{userid}", 'DELETE'
  if svn_user_removal['id']
    ui.success "#{userid} has been removed from the SVN users."
  else
    ui.fail AcquiaToolbelt::CLI::API.display_error(svn_user_removal)
  end
end

#listObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/acquia_toolbelt/cli/svn.rb', line 8

def list
  if options[:subscription]
    subscription = options[:subscription]
  else
    subscription = AcquiaToolbelt::CLI::API.default_subscription
  end

  svn_users = AcquiaToolbelt::CLI::API.request  "sites/#{subscription}/svnusers"
  svn_users.each do |user|
    ui.say
    ui.say "> ID: #{user['id']}"
    ui.say "> Name: #{user['username']}"
  end
end