Class: Conjur::Command
- Inherits:
-
Object
show all
- Defined in:
- lib/conjur/command.rb
Direct Known Subclasses
Assets, Authn, Field, Groups, Hosts, Id, Resources, Roles, Secrets, Users, Variables
Defined Under Namespace
Classes: Assets, Authn, Field, Groups, Hosts, Id, Resources, Roles, Secrets, Users, Variables
Constant Summary
collapse
- @@api =
nil
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.prefix ⇒ Object
Returns the value of attribute prefix.
6
7
8
|
# File 'lib/conjur/command.rb', line 6
def prefix
@prefix
end
|
Class Method Details
.acting_as_option(command) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/conjur/command.rb', line 28
def acting_as_option(command)
command.arg_name 'Perform all actions as the specified Group'
command.flag [:"as-group"]
command.arg_name 'Perform all actions as the specified Role'
command.flag [:"as-role"]
end
|
.api ⇒ Object
20
21
22
|
# File 'lib/conjur/command.rb', line 20
def api
@@api ||= Conjur::Authn.connect
end
|
.command(name, *a, &block) ⇒ Object
12
13
14
|
# File 'lib/conjur/command.rb', line 12
def command name, *a, &block
Conjur::CLI.command "#{prefix}:#{name}", *a, &block
end
|
.conjur_account ⇒ Object
24
25
26
|
# File 'lib/conjur/command.rb', line 24
def conjur_account
Conjur::Core::API.conjur_account
end
|
.display(obj, options = {}) ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/conjur/command.rb', line 36
def display(obj, options = {})
str = if obj.respond_to?(:attributes)
JSON.pretty_generate obj.attributes
elsif obj.respond_to?(:id)
obj.id
else
JSON.pretty_generate obj
end
puts str
end
|
.method_missing(*a) ⇒ Object
8
9
10
|
# File 'lib/conjur/command.rb', line 8
def method_missing *a
Conjur::CLI.send *a
end
|
.require_arg(args, name) ⇒ Object
16
17
18
|
# File 'lib/conjur/command.rb', line 16
def require_arg(args, name)
args.shift or raise "Missing parameter: #{name}"
end
|