Class: OvirtSDK4::AssignedTagsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::AssignedTagsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Tag) add(tag, opts = {})
Adds a new
tag
. -
- (Array<Tag>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (AssignedTagService) tag_service(id)
Locates the
tag
service. -
- (String) to_s
Returns an string representation of this service.
Instance Method Details
- (Tag) add(tag, opts = {})
Adds a new tag
.
2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 |
# File 'lib/ovirtsdk4/services.rb', line 2960 def add(tag, opts = {}) if tag.is_a?(Hash) tag = OvirtSDK4::Tag.new(tag) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) TagWriter.write_one(tag, writer, 'tag') 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 TagReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Array<Tag>) list(opts = {})
Returns the representation of the object managed by this service.
2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 |
# File 'lib/ovirtsdk4/services.rb', line 2995 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 TagReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 |
# File 'lib/ovirtsdk4/services.rb', line 3035 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return tag_service(path) end return tag_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (AssignedTagService) tag_service(id)
Locates the tag
service.
3024 3025 3026 |
# File 'lib/ovirtsdk4/services.rb', line 3024 def tag_service(id) return AssignedTagService.new(@connection, "#{@path}/#{id}") end |
- (String) to_s
Returns an string representation of this service.
3051 3052 3053 |
# File 'lib/ovirtsdk4/services.rb', line 3051 def to_s return "#<#{AssignedTagsService}:#{@path}>" end |