Class: Windoo::Patch

Inherits:
BaseClasses::JSONObject show all
Includes:
Mixins::APICollection, Mixins::Patch::Component
Defined in:
lib/windoo/objects/patch.rb

Overview

A patch represents a specific version of a Software Title.

Constant Summary collapse

RSRC_PATH =

Constants

'patches'
CONTAINER_CLASS =
Windoo::SoftwareTitle
JSON_ATTRIBUTES =

Attributes

{

  # @!attribute patchId
  # @return [Integer] The id number of this patch
  patchId: {
    class: :Integer,
    identifier: :primary,
    do_not_send: true,
    readonly: true
  },

  # @!attribute softwareTitleId
  # @return [Integer] The id number of the title which uses this patch
  softwareTitleId: {
    class: :Integer,
    do_not_send: true,
    readonly: true
  },

  # @!attribute absoluteOrderId
  # @return [Integer] The zero-based position of this patch among
  #   all those used by the title. Should be identical to the Array index
  #   of this patch in the #patches attribute of the SoftwareTitle
  #   instance that uses this patch.
  #   NOTE: This can only be changed via methods called on the
  #   PatchManager that contains the patch.
  absoluteOrderId: {
    class: :Integer,
    readonly: true
  },

  # @!attribute enabled
  # @return [Boolean] Is this patch enabled?
  enabled: {
    class: :Boolean
  },

  # @!attribute version
  # @return [String] The version on the title installed by this patch
  version: {
    class: :String,
    required: true
  },

  # @!attribute releaseDate
  # @return [Time] When this patch was released
  releaseDate: {
    class: :Time,
    required: true,
    to_ruby: :to_time,
    to_api: :time_to_api
  },

  # @!attribute standalone
  # @return [Boolean] Can this patch be installed as an initial installation?
  #   If not, it must be applied to an already-installed version of this title.
  #   NOTE: This is for reporting only, it is not used in patch policies
  standalone: {
    class: :Boolean
  },

  # @!attribute minimumOperatingSystem
  # @return [String] The lowest version of the OS that can run this patch
  #   NOTE: This is for reporting only. If there is a minimumOperatingSystem
  #   You'll still need to specify it in the capabilities for this patch.
  minimumOperatingSystem: {
    class: :String,
    required: true
  },

  # @!attribute reboot
  # @return [Boolean] Does the patch require a reboot after installation?
  reboot: {
    class: :Boolean
  },

  # @!attribute killApps
  # @return [Array<Windoo::KillApp>] The apps that must be quit before
  #   installing this patch
  killApps: {
    class: Windoo::KillAppManager,
    do_not_send: true,
    readonly: true
  },

  # @!attribute components
  # @return [Array<Windoo::Component>] The components of this patch.
  #   NOTE: there can be only one!
  component: {
    class: Windoo::Component,
    do_not_send: true,
    readonly: true
  },

  # @!attribute capabilities
  # @return [Array<Windoo::CapabilityManager>] The criteria which identify
  #   computers capable of running, and thus installing, this patch.
  capabilities: {
    class: Windoo::CapabilityManager,
    do_not_send: true,
    readonly: true
  }

}.freeze

Constants inherited from BaseClasses::JSONObject

BaseClasses::JSONObject::PP_OMITTED_INST_VARS

Instance Attribute Summary collapse

Attributes inherited from BaseClasses::JSONObject

#init_data

Instance Method Summary collapse

Methods included from Mixins::Patch::Component

#add_component, #delete_component

Methods included from Mixins::APICollection

#==, #cnx, #container, #create_on_server, #delete, #deleted_id, included, #pretty_print_instance_variables, #primary_id, #softwareTitle, #update_on_server

Methods inherited from BaseClasses::JSONObject

attribute_already_parsed?, ident_keys, json_attributes, json_attributes_parsed, mutable?, parse_json_attributes, #pretty_print_instance_variables, primary_id_key, required_attributes, #to_api, #to_json, validate_attr

Constructor Details

#initialize(**init_data) ⇒ Patch

Constructor



137
138
139
140
141
# File 'lib/windoo/objects/patch.rb', line 137

def initialize(**init_data)
  super
  @capabilities = Windoo::CapabilityManager.new @capabilities, container: self
  @killApps = Windoo::KillAppManager.new @killApps, container: self
end

Instance Attribute Details

#absoluteOrderIdInteger

Returns The zero-based position of this patch among all those used by the title. Should be identical to the Array index of this patch in the #patches attribute of the SoftwareTitle instance that uses this patch. NOTE: This can only be changed via methods called on the PatchManager that contains the patch.

Returns:

  • (Integer)

    The zero-based position of this patch among all those used by the title. Should be identical to the Array index of this patch in the #patches attribute of the SoftwareTitle instance that uses this patch. NOTE: This can only be changed via methods called on the PatchManager that contains the patch.



# File 'lib/windoo/objects/patch.rb', line 48

#capabilitiesArray<Windoo::CapabilityManager>

Returns The criteria which identify computers capable of running, and thus installing, this patch.

Returns:

  • (Array<Windoo::CapabilityManager>)

    The criteria which identify computers capable of running, and thus installing, this patch.



# File 'lib/windoo/objects/patch.rb', line 123

#componentsArray<Windoo::Component>

Returns The components of this patch. NOTE: there can be only one!.

Returns:

  • (Array<Windoo::Component>)

    The components of this patch. NOTE: there can be only one!



# File 'lib/windoo/objects/patch.rb', line 114

#enabledBoolean

Returns Is this patch enabled?.

Returns:

  • (Boolean)

    Is this patch enabled?



# File 'lib/windoo/objects/patch.rb', line 60

#killAppsArray<Windoo::KillApp>

Returns The apps that must be quit before installing this patch.

Returns:

  • (Array<Windoo::KillApp>)

    The apps that must be quit before installing this patch



# File 'lib/windoo/objects/patch.rb', line 105

#minimumOperatingSystemString

Returns The lowest version of the OS that can run this patch NOTE: This is for reporting only. If there is a minimumOperatingSystem You’ll still need to specify it in the capabilities for this patch.

Returns:

  • (String)

    The lowest version of the OS that can run this patch NOTE: This is for reporting only. If there is a minimumOperatingSystem You’ll still need to specify it in the capabilities for this patch.



# File 'lib/windoo/objects/patch.rb', line 90

#patchIdInteger

Returns The id number of this patch.

Returns:

  • (Integer)

    The id number of this patch



# File 'lib/windoo/objects/patch.rb', line 31

#rebootBoolean

Returns Does the patch require a reboot after installation?.

Returns:

  • (Boolean)

    Does the patch require a reboot after installation?



# File 'lib/windoo/objects/patch.rb', line 99

#releaseDateTime

Returns When this patch was released.

Returns:

  • (Time)

    When this patch was released



# File 'lib/windoo/objects/patch.rb', line 73

#softwareTitleIdInteger

Returns The id number of the title which uses this patch.

Returns:

  • (Integer)

    The id number of the title which uses this patch



# File 'lib/windoo/objects/patch.rb', line 40

#standaloneBoolean

Returns Can this patch be installed as an initial installation? If not, it must be applied to an already-installed version of this title. NOTE: This is for reporting only, it is not used in patch policies.

Returns:

  • (Boolean)

    Can this patch be installed as an initial installation? If not, it must be applied to an already-installed version of this title. NOTE: This is for reporting only, it is not used in patch policies



# File 'lib/windoo/objects/patch.rb', line 82

#versionString

Returns The version on the title installed by this patch.

Returns:

  • (String)

    The version on the title installed by this patch



# File 'lib/windoo/objects/patch.rb', line 66

Instance Method Details

#disableObject

Disable this Patch



165
166
167
168
169
170
# File 'lib/windoo/objects/patch.rb', line 165

def disable
  return unless enabled?

  self.enabled = false
  :disabled
end

#enableObject

Enable this Patch



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/windoo/objects/patch.rb', line 147

def enable
  return if enabled?

  if capabilities.empty? || component.nil? || component.criteria.empty?
    raise Windoo::MissingDataError,
          'Patches must have at least one capability, and a component with at least one criterion, before they can be enabled'
  end

  self.enabled = true

  # Update the currentVersion of our title to this version if this patch is the
  # newest enabled patch
  container.currentVersion = version if container.patches.all_enabled.first == self

  :enabled
end

#local_absoluteOrderId=(new_index) ⇒ void

TODO:

Only allow this to be called from a PatchManager.

This method returns an undefined value.

Update the local absoluteOrderId without updating it on the server.

Why??

Because changing the value on the server for one criterion using #absoluteOrderId= will automatically change it on the server for all the others.

After changing one on the server and updating that one in the local array, the ArrayManager will use this, without updating the server, to change the value for all others in the array to match their array index.



206
207
208
# File 'lib/windoo/objects/patch.rb', line 206

def local_absoluteOrderId=(new_index)
  @absoluteOrderId = new_index
end