Class: OvirtSDK4::VirtualFunctionAllowedNetworksService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::VirtualFunctionAllowedNetworksService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Network) add(network, opts = {})
Adds a new
network
. -
- (Array<Network>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (VirtualFunctionAllowedNetworkService) network_service(id)
Locates the
network
service. -
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
Instance Method Details
- (Network) add(network, opts = {})
Adds a new network
.
23245 23246 23247 23248 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 23261 23262 23263 23264 23265 23266 23267 23268 23269 |
# File 'lib/ovirtsdk4/services.rb', line 23245 def add(network, opts = {}) if network.is_a?(Hash) network = OvirtSDK4::Network.new(network) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) NetworkWriter.write_one(network, writer, 'network') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 201, 202 begin reader = XmlReader.new(response.body) return NetworkReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Array<Network>) list(opts = {})
Returns the representation of the object managed by this service.
23280 23281 23282 23283 23284 23285 23286 23287 23288 23289 23290 23291 23292 23293 23294 23295 23296 23297 23298 23299 23300 |
# File 'lib/ovirtsdk4/services.rb', line 23280 def list(opts = {}) query = {} value = opts[:max] unless value.nil? value = Writer.render_integer(value) query['max'] = value end request = Request.new(:method => :GET, :path => @path, :query => query) response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return NetworkReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (VirtualFunctionAllowedNetworkService) network_service(id)
Locates the network
service.
23309 23310 23311 |
# File 'lib/ovirtsdk4/services.rb', line 23309 def network_service(id) return VirtualFunctionAllowedNetworkService.new(@connection, "#{@path}/#{id}") end |
- (Service) service(path)
Locates the service corresponding to the given path.
23320 23321 23322 23323 23324 23325 23326 23327 23328 23329 |
# File 'lib/ovirtsdk4/services.rb', line 23320 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return network_service(path) end return network_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
23336 23337 23338 |
# File 'lib/ovirtsdk4/services.rb', line 23336 def to_s return "#<#{VirtualFunctionAllowedNetworksService}:#{@path}>" end |