Class: OvirtSDK4::AffinityGroupsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::AffinityGroupsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (AffinityGroup) add(group, opts = {})
Adds a new
group
. -
- (AffinityGroupService) group_service(id)
Locates the
group
service. -
- (Array<AffinityGroup>) 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
- (AffinityGroup) add(group, opts = {})
Adds a new group
.
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
# File 'lib/ovirtsdk4/services.rb', line 1064 def add(group, opts = {}) if group.is_a?(Hash) group = OvirtSDK4::AffinityGroup.new(group) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) AffinityGroupWriter.write_one(group, writer, 'group') 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 AffinityGroupReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (AffinityGroupService) group_service(id)
Locates the group
service.
1128 1129 1130 |
# File 'lib/ovirtsdk4/services.rb', line 1128 def group_service(id) return AffinityGroupService.new(@connection, "#{@path}/#{id}") end |
- (Array<AffinityGroup>) list(opts = {})
Returns the representation of the object managed by this service.
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 |
# File 'lib/ovirtsdk4/services.rb', line 1099 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 AffinityGroupReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 |
# File 'lib/ovirtsdk4/services.rb', line 1139 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return group_service(path) end return group_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
1155 1156 1157 |
# File 'lib/ovirtsdk4/services.rb', line 1155 def to_s return "#<#{AffinityGroupsService}:#{@path}>" end |