Class: PuppetX::Wildfly::OperationBuilder
- Inherits:
-
Object
- Object
- PuppetX::Wildfly::OperationBuilder
- Defined in:
- lib/puppet_x/wildfly/operation_builder.rb
Instance Method Summary collapse
- #add(name) ⇒ Object
- #add_content(name, source) ⇒ Object
- #build ⇒ Object
- #composite(*steps) ⇒ Object
- #deploy(name) ⇒ Object
- #headers(headers) ⇒ Object
-
#initialize ⇒ OperationBuilder
constructor
A new instance of OperationBuilder.
- #path_to_address(path) ⇒ Object
- #read(name) ⇒ Object
- #remove(name) ⇒ Object
- #remove_content(name) ⇒ Object
- #target(name) ⇒ Object
- #undeploy(name) ⇒ Object
- #with(state) ⇒ Object
- #write_attribute(path, attribute, value) ⇒ Object
Constructor Details
#initialize ⇒ OperationBuilder
Returns a new instance of OperationBuilder.
6 7 8 9 10 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 6 def initialize @detyped_request = { :address => [] } end |
Instance Method Details
#add(name) ⇒ Object
19 20 21 22 23 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 19 def add(name) @detyped_request[:operation] = :add @detyped_request[:address] = path_to_address(name) self end |
#add_content(name, source) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 51 def add_content(name, source) @detyped_request[:operation] = :add @detyped_request[:content] = [:url => "file:#{source}"] @detyped_request[:address] << { :deployment => name } self end |
#build ⇒ Object
93 94 95 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 93 def build @detyped_request end |
#composite(*steps) ⇒ Object
72 73 74 75 76 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 72 def composite(*steps) @detyped_request[:operation] = :composite @detyped_request[:steps] = steps self end |
#deploy(name) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 58 def deploy(name) operation = @detyped_request[:address].empty? ? :deploy : :add @detyped_request[:operation] = operation @detyped_request[:address] << { :deployment => name } self end |
#headers(headers) ⇒ Object
78 79 80 81 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 78 def headers(headers) @detyped_request['operation-headers'] = headers self end |
#path_to_address(path) ⇒ Object
88 89 90 91 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 88 def path_to_address(path) # change grammar to avoid :dummy CLICommand.new("#{path}:dummy").address end |
#read(name) ⇒ Object
25 26 27 28 29 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 25 def read(name) @detyped_request[:operation] = 'read-resource' @detyped_request[:address] = path_to_address(name) self end |
#remove(name) ⇒ Object
39 40 41 42 43 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 39 def remove(name) @detyped_request[:operation] = :remove @detyped_request[:address] = path_to_address(name) self end |
#remove_content(name) ⇒ Object
45 46 47 48 49 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 45 def remove_content(name) @detyped_request[:operation] = :remove @detyped_request[:address] << { :deployment => name } self end |
#target(name) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 12 def target(name) unless name.nil? @detyped_request[:address] << { 'server-group' => name } end self end |
#undeploy(name) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 65 def undeploy(name) operation = @detyped_request[:address].empty? ? :undeploy : :remove @detyped_request[:operation] = operation @detyped_request[:address] << { :deployment => name } self end |
#with(state) ⇒ Object
83 84 85 86 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 83 def with(state) @detyped_request.merge!(state) self end |
#write_attribute(path, attribute, value) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/puppet_x/wildfly/operation_builder.rb', line 31 def write_attribute(path, attribute, value) @detyped_request[:operation] = 'write-attribute' @detyped_request[:address] = path_to_address(path) @detyped_request[:name] = attribute @detyped_request[:value] = value self end |