Class: OvirtSDK4::SshPublicKeysService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary collapse

Methods inherited from Service

#inspect, #to_s

Instance Method Details

#add(key, opts = {}) ⇒ SshPublicKey

Adds a new key.

Parameters:

  • key (SshPublicKey)

    The key to add.

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



21638
21639
21640
# File 'lib/ovirtsdk4/services.rb', line 21638

def add(key, opts = {})
  internal_add(key, SshPublicKey, ADD, opts)
end

#key_service(id) ⇒ SshPublicKeyService

Locates the key service.

Parameters:

  • id (String)

    The identifier of the key.

Returns:



21722
21723
21724
# File 'lib/ovirtsdk4/services.rb', line 21722

def key_service(id)
  SshPublicKeyService.new(self, id)
end

#list(opts = {}) ⇒ Array<SshPublicKey>

Returns a list of SSH public keys of the user.

For example, to retrieve the list of SSH keys of user with identifier 123, send a request like this:

GET /ovirt-engine/api/users/123/sshpublickeys

The result will be the following XML document:

<ssh_public_keys>
  <ssh_public_key href="/ovirt-engine/api/users/123/sshpublickeys/456" id="456">
    <content>ssh-rsa ...</content>
    <user href="/ovirt-engine/api/users/123" id="123"/>
  </ssh_public_key>
</ssh_public_keys>

Or the following JSON object

{
  "ssh_public_key": [
    {
      "content": "ssh-rsa ...",
      "user": {
        "href": "/ovirt-engine/api/users/123",
        "id": "123"
      },
      "href": "/ovirt-engine/api/users/123/sshpublickeys/456",
      "id": "456"
    }
  ]
}

The order of the returned list of keys is not guaranteed.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :follow (String)

    Indicates which inner links should be followed. The objects referenced by these links will be fetched as part of the current request. See here for details.

  • :max (Integer)

    Sets the maximum number of keys to return. If not specified all the keys are returned.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



21711
21712
21713
# File 'lib/ovirtsdk4/services.rb', line 21711

def list(opts = {})
  internal_get(LIST, opts)
end

#service(path) ⇒ Service

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.



21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
# File 'lib/ovirtsdk4/services.rb', line 21733

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