Class: OvirtSDK4::LabelsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::LabelsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Label) add(label, opts = {})
Adds a new
label
. -
- (LabelService) label_service(id)
Locates the
label
service. -
- (Array<Label>) 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
- (Label) add(label, opts = {})
Adds a new label
.
10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 |
# File 'lib/ovirtsdk4/services.rb', line 10787 def add(label, opts = {}) if label.is_a?(Hash) label = OvirtSDK4::Label.new(label) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) LabelWriter.write_one(label, writer, 'label') 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 LabelReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (LabelService) label_service(id)
Locates the label
service.
10851 10852 10853 |
# File 'lib/ovirtsdk4/services.rb', line 10851 def label_service(id) return LabelService.new(@connection, "#{@path}/#{id}") end |
- (Array<Label>) list(opts = {})
Returns the representation of the object managed by this service.
10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 |
# File 'lib/ovirtsdk4/services.rb', line 10822 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 LabelReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 |
# File 'lib/ovirtsdk4/services.rb', line 10862 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return label_service(path) end return label_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
10878 10879 10880 |
# File 'lib/ovirtsdk4/services.rb', line 10878 def to_s return "#<#{LabelsService}:#{@path}>" end |