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:



2897
2898
2899
# File 'lib/ovirtsdk4/services.rb', line 2897

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:



2948
2949
2950
# File 'lib/ovirtsdk4/services.rb', line 2948

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.



2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
# File 'lib/ovirtsdk4/services.rb', line 2970

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:



2959
2960
2961
# File 'lib/ovirtsdk4/services.rb', line 2959

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