Class: OvirtSDK4::AssignedTagsService

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

Assign tag to specific entity in the system.

For example to assign tag mytag to virtual machine with the id 123 send a request like this:

POST /ovirt-engine/api/vms/123/tags

With a request body like this:

<tag>
  <name>mytag</name>
</tag>

Parameters:

  • tag (Tag)

    The assigned tag.

  • 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:



3476
3477
3478
# File 'lib/ovirtsdk4/services.rb', line 3476

def add(tag, opts = {})
  internal_add(tag, Tag, ADD, opts)
end

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

List all tags assigned to the specific entity.

For example to list all the tags of the virtual machine with id 123 send a request like this:

GET /ovirt-engine/api/vms/123/tags
<tags>
  <tag href="/ovirt-engine/api/tags/222" id="222">
    <name>mytag</name>
    <description>mytag</description>
    <vm href="/ovirt-engine/api/vms/123" id="123"/>
  </tag>
</tags>

The order of the returned tags 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 tags to return. If not specified all the tags 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:



3527
3528
3529
# File 'lib/ovirtsdk4/services.rb', line 3527

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.



3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
# File 'lib/ovirtsdk4/services.rb', line 3549

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

#tag_service(id) ⇒ AssignedTagService

Reference to the service that manages assignment of specific tag.

Parameters:

  • id (String)

    The identifier of the tag.

Returns:



3538
3539
3540
# File 'lib/ovirtsdk4/services.rb', line 3538

def tag_service(id)
  AssignedTagService.new(self, id)
end