Class: OvirtSDK4::EventsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::EventsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Event) add(event, opts = {})
Adds a new
event
. -
- (EventService) event_service(id)
Locates the
event
service. -
- (Array<Event>) 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.
-
- (Object) undelete(opts = {})
Executes the
undelete
method.
Instance Method Details
- (Event) add(event, opts = {})
Adds a new event
.
6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 |
# File 'lib/ovirtsdk4/services.rb', line 6660 def add(event, opts = {}) if event.is_a?(Hash) event = OvirtSDK4::Event.new(event) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) EventWriter.write_one(event, writer, 'event') 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 EventReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (EventService) event_service(id)
Locates the event
service.
6762 6763 6764 |
# File 'lib/ovirtsdk4/services.rb', line 6762 def event_service(id) return EventService.new(@connection, "#{@path}/#{id}") end |
- (Array<Event>) list(opts = {})
Returns the representation of the object managed by this service.
6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 |
# File 'lib/ovirtsdk4/services.rb', line 6701 def list(opts = {}) query = {} value = opts[:case_sensitive] unless value.nil? value = Writer.render_boolean(value) query['case_sensitive'] = value end value = opts[:max] unless value.nil? value = Writer.render_integer(value) query['max'] = value end value = opts[:search] unless value.nil? query['search'] = 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 EventReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 |
# File 'lib/ovirtsdk4/services.rb', line 6773 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return event_service(path) end return event_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
6789 6790 6791 |
# File 'lib/ovirtsdk4/services.rb', line 6789 def to_s return "#<#{EventsService}:#{@path}>" end |
- (Object) undelete(opts = {})
Executes the undelete
method.
6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 |
# File 'lib/ovirtsdk4/services.rb', line 6735 def undelete(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/undelete", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |