Class: OvirtSDK4::SshPublicKeysService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::SshPublicKeysService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (SshPublicKey) add(key, opts = {})
Adds a new
key
. -
- (SshPublicKeyService) key_service(id)
Locates the
key
service. -
- (Array<SshPublicKey>) 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
- (SshPublicKey) add(key, opts = {})
Adds a new key
.
18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 |
# File 'lib/ovirtsdk4/services.rb', line 18077 def add(key, opts = {}) if key.is_a?(Hash) key = OvirtSDK4::SshPublicKey.new(key) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) SshPublicKeyWriter.write_one(key, writer, 'key') 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 SshPublicKeyReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (SshPublicKeyService) key_service(id)
Locates the key
service.
18141 18142 18143 |
# File 'lib/ovirtsdk4/services.rb', line 18141 def key_service(id) return SshPublicKeyService.new(@connection, "#{@path}/#{id}") end |
- (Array<SshPublicKey>) list(opts = {})
Returns the representation of the object managed by this service.
18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 |
# File 'lib/ovirtsdk4/services.rb', line 18112 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 SshPublicKeyReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 |
# File 'lib/ovirtsdk4/services.rb', line 18152 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return key_service(path) end return key_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
18168 18169 18170 |
# File 'lib/ovirtsdk4/services.rb', line 18168 def to_s return "#<#{SshPublicKeysService}:#{@path}>" end |