Module: WinRM::WSMV::Header
- Included in:
- Base, ReceiveResponseReader
- Defined in:
- lib/winrm/wsmv/header.rb
Overview
SOAP header utility mixin
Constant Summary collapse
- RESOURCE_URI_CMD =
WSMan URI of the regular Windows cmd shell
'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd'.freeze
- RESOURCE_URI_POWERSHELL =
WSMan URI for PowerShell
'http://schemas.microsoft.com/powershell/Microsoft.PowerShell'.freeze
Instance Method Summary collapse
- #action_command ⇒ Object
- #action_delete ⇒ Object
- #action_enumerate ⇒ Object
- #action_enumerate_pull ⇒ Object
- #action_get ⇒ Object
- #action_receive ⇒ Object
- #action_send ⇒ Object
- #action_signal ⇒ Object
-
#merge_headers(*headers) ⇒ Object
Merge the various header hashes and make sure we carry all of the attributes through instead of overwriting them.
- #resource_uri_cmd ⇒ Object
-
#resource_uri_shell(shell_uri) ⇒ Object
Helper methods for SOAP Headers.
- #resource_uri_wmi(namespace = 'root/cimv2/*') ⇒ Object
- #selector_shell_id(shell_id) ⇒ Object
- #shared_headers(session_opts) ⇒ Object
Instance Method Details
#action_command ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/winrm/wsmv/header.rb', line 128 def action_command { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_delete ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/winrm/wsmv/header.rb', line 116 def action_delete { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_enumerate ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/winrm/wsmv/header.rb', line 176 def action_enumerate { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_enumerate_pull ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/winrm/wsmv/header.rb', line 188 def action_enumerate_pull { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_get ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/winrm/wsmv/header.rb', line 104 def action_get { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_receive ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/winrm/wsmv/header.rb', line 140 def action_receive { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_send ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/winrm/wsmv/header.rb', line 152 def action_send { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Send', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_signal ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/winrm/wsmv/header.rb', line 164 def action_signal { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Signal', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#merge_headers(*headers) ⇒ Object
Merge the various header hashes and make sure we carry all of the attributes through instead of overwriting them.
34 35 36 37 38 39 40 41 42 |
# File 'lib/winrm/wsmv/header.rb', line 34 def merge_headers(*headers) hdr = {} headers.each do |h| hdr.merge!(h) do |k, v1, v2| v1.merge!(v2) if k == :attributes! end end hdr end |
#resource_uri_cmd ⇒ Object
88 89 90 |
# File 'lib/winrm/wsmv/header.rb', line 88 def resource_uri_cmd resource_uri_shell(RESOURCE_URI_CMD) end |
#resource_uri_shell(shell_uri) ⇒ Object
Helper methods for SOAP Headers
78 79 80 81 82 83 84 85 86 |
# File 'lib/winrm/wsmv/header.rb', line 78 def resource_uri_shell(shell_uri) { "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => shell_uri, :attributes! => { "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => { 'mustUnderstand' => true } } } end |
#resource_uri_wmi(namespace = 'root/cimv2/*') ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/winrm/wsmv/header.rb', line 92 def resource_uri_wmi(namespace = 'root/cimv2/*') { "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => "http://schemas.microsoft.com/wbem/wsman/1/wmi/#{namespace}", :attributes! => { "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => { 'mustUnderstand' => true } } } end |
#selector_shell_id(shell_id) ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/winrm/wsmv/header.rb', line 200 def selector_shell_id(shell_id) { "#{SOAP::NS_WSMAN_DMTF}:SelectorSet" => { "#{SOAP::NS_WSMAN_DMTF}:Selector" => shell_id, :attributes! => { "#{SOAP::NS_WSMAN_DMTF}:Selector" => { 'Name' => 'ShellId' } } } } end |
#shared_headers(session_opts) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/winrm/wsmv/header.rb', line 44 def shared_headers(session_opts) { "#{SOAP::NS_ADDRESSING}:To" => session_opts[:endpoint], "#{SOAP::NS_ADDRESSING}:ReplyTo" => { "#{SOAP::NS_ADDRESSING}:Address" => 'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous', :attributes! => { "#{SOAP::NS_ADDRESSING}:Address" => { 'mustUnderstand' => true } } }, "#{SOAP::NS_WSMAN_DMTF}:MaxEnvelopeSize" => session_opts[:max_envelope_size], "#{SOAP::NS_ADDRESSING}:MessageID" => "uuid:#{SecureRandom.uuid.to_s.upcase}", "#{SOAP::NS_WSMAN_MSFT}:SessionId" => "uuid:#{session_opts[:session_id]}", "#{SOAP::NS_WSMAN_DMTF}:Locale/" => '', "#{SOAP::NS_WSMAN_MSFT}:DataLocale/" => '', "#{SOAP::NS_WSMAN_DMTF}:OperationTimeout" => Iso8601Duration.sec_to_dur(session_opts[:operation_timeout]), :attributes! => { "#{SOAP::NS_WSMAN_DMTF}:MaxEnvelopeSize" => { 'mustUnderstand' => true }, "#{SOAP::NS_WSMAN_DMTF}:Locale/" => { 'xml:lang' => session_opts[:locale], 'mustUnderstand' => false }, "#{SOAP::NS_WSMAN_MSFT}:DataLocale/" => { 'xml:lang' => session_opts[:locale], 'mustUnderstand' => false }, "#{SOAP::NS_WSMAN_MSFT}:SessionId" => { 'mustUnderstand' => false } } } end |