Class: OvirtSDK4::PermitsService

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(permit, opts = {}) ⇒ Permit

Adds a permit to the role. The permit name can be retrieved from the [services/cluster_levels] service.

For example to assign a permit create_vm to the role with id 123 send a request like this:

POST /ovirt-engine/api/roles/123/permits

With a request body like this:

<permit>
  <name>create_vm</name>
</permit>

Parameters:

  • permit (Permit)

    The permit 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:


18806
18807
18808
# File 'lib/ovirtsdk4/services.rb', line 18806

def add(permit, opts = {})
  internal_add(permit, Permit, ADD, opts)
end

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

List the permits of the role.

For example to list the permits of the role with the id 123 send a request like this:

GET /ovirt-engine/api/roles/123/permits
<permits>
  <permit href="/ovirt-engine/api/roles/123/permits/5" id="5">
    <name>change_vm_cd</name>
    <administrative>false</administrative>
    <role href="/ovirt-engine/api/roles/123" id="123"/>
  </permit>
  <permit href="/ovirt-engine/api/roles/123/permits/7" id="7">
    <name>connect_to_vm</name>
    <administrative>false</administrative>
    <role href="/ovirt-engine/api/roles/123" id="123"/>
  </permit>
</permits>

The order of the returned list of permits isn’t 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 permits to return. If not specified all the permits 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:


18862
18863
18864
# File 'lib/ovirtsdk4/services.rb', line 18862

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

#permit_service(id) ⇒ PermitService

Sub-resource locator method, returns individual permit resource on which the remainder of the URI is dispatched.

Parameters:

  • id (String)

    The identifier of the permit.

Returns:


18873
18874
18875
# File 'lib/ovirtsdk4/services.rb', line 18873

def permit_service(id)
  PermitService.new(self, id)
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.


18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
# File 'lib/ovirtsdk4/services.rb', line 18884

def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return permit_service(path)
  end
  return permit_service(path[0..(index - 1)]).service(path[(index + 1)..-1])
end