Class: OvirtSDK4::NetworkLabelsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::NetworkLabelsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (NetworkLabel) add(label, opts = {})
Adds a new
label
. -
- (NetworkLabelService) label_service(id)
Locates the
label
service. -
- (Array<NetworkLabel>) 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
- (NetworkLabel) add(label, opts = {})
Adds a new label
.
12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 |
# File 'lib/ovirtsdk4/services.rb', line 12975 def add(label, opts = {}) if label.is_a?(Hash) label = OvirtSDK4::NetworkLabel.new(label) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) NetworkLabelWriter.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 NetworkLabelReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (NetworkLabelService) label_service(id)
Locates the label
service.
13039 13040 13041 |
# File 'lib/ovirtsdk4/services.rb', line 13039 def label_service(id) return NetworkLabelService.new(@connection, "#{@path}/#{id}") end |
- (Array<NetworkLabel>) list(opts = {})
Returns the representation of the object managed by this service.
13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 |
# File 'lib/ovirtsdk4/services.rb', line 13010 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 NetworkLabelReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 |
# File 'lib/ovirtsdk4/services.rb', line 13050 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.
13066 13067 13068 |
# File 'lib/ovirtsdk4/services.rb', line 13066 def to_s return "#<#{NetworkLabelsService}:#{@path}>" end |