Class: OvirtSDK4::NetworkAttachmentsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::NetworkAttachmentsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (NetworkAttachment) add(attachment, opts = {})
Adds a new
attachment
. -
- (NetworkAttachmentService) attachment_service(id)
Locates the
attachment
service. -
- (Array<NetworkAttachment>) list(opts = {})
Returns the representation of the object managed by this 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
- (NetworkAttachment) add(attachment, opts = {})
Adds a new attachment
.
12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 |
# File 'lib/ovirtsdk4/services.rb', line 12624 def add(, opts = {}) if .is_a?(Hash) = OvirtSDK4::NetworkAttachment.new() end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) NetworkAttachmentWriter.write_one(, writer, 'attachment') 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 NetworkAttachmentReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (NetworkAttachmentService) attachment_service(id)
Locates the attachment
service.
12688 12689 12690 |
# File 'lib/ovirtsdk4/services.rb', line 12688 def (id) return NetworkAttachmentService.new(@connection, "#{@path}/#{id}") end |
- (Array<NetworkAttachment>) list(opts = {})
Returns the representation of the object managed by this service.
12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 |
# File 'lib/ovirtsdk4/services.rb', line 12659 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 NetworkAttachmentReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 |
# File 'lib/ovirtsdk4/services.rb', line 12699 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return (path) end return (path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
12715 12716 12717 |
# File 'lib/ovirtsdk4/services.rb', line 12715 def to_s return "#<#{NetworkAttachmentsService}:#{@path}>" end |