Class: Windoo::ExtensionAttribute

Inherits:
BaseClasses::JSONObject show all
Includes:
Mixins::APICollection
Defined in:
lib/windoo/objects/extension_attribute.rb

Overview

The class for dealing with Software Title ExtensionAttributes in the TitleEditor.

NOTE: Do not create or delete instances of this class directly. use:

- SoftwareTitle#add_extensionAttribute
  - From {SoftwareTitle#add_extensionAttribute}

and

- SoftwareTitle#delete_extensionAttribute
  - From {SoftwareTitle#delete_extensionAttribute}

Constant Summary collapse

RSRC_PATH =

Constants

'extensionattributes'
CONTAINER_CLASS =
Windoo::SoftwareTitle
JSON_ATTRIBUTES =

Attributes

{

  # @!attribute extensionAttributeId
  # @return [Integer] The id number of this extension attribute in the Title Editor
  extensionAttributeId: {
    class: :Integer,
    identifier: :primary,
    do_not_send: true,
    readonly: true
  },

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

  # @!attribute key
  # @return [String] The name of the extension attribute as it appears in Jamf Pro
  #    NOTE: must be unique in the Title Editor AND Jamf Pro.
  key: {
    class: :String,
    required: true,
    identifier: true
  },

  # @!attribute value
  # @return [String] The Base64 encoded script for this extension attribute
  value: {
    class: :String
  },

  # @!attribute displayName
  # @return [String] The name of the extension attribute as it appears in Title Editor
  displayName: {
    class: :String,
    required: true
  }

}.freeze

Constants inherited from BaseClasses::JSONObject

BaseClasses::JSONObject::PP_OMITTED_INST_VARS

Instance Attribute Summary collapse

Attributes inherited from BaseClasses::JSONObject

#init_data

Class Method Summary collapse

Instance Method Summary collapse

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) ⇒ ExtensionAttribute

Construcor



100
101
102
103
104
105
106
# File 'lib/windoo/objects/extension_attribute.rb', line 100

def initialize(**init_data)
  # If we were given a raw script when creating a new
  # EA, save it here  and we'll process it in #create_on_server
  @script = init_data[:script]

  super
end

Instance Attribute Details

#displayNameString

Returns The name of the extension attribute as it appears in Title Editor.

Returns:

  • (String)

    The name of the extension attribute as it appears in Title Editor



# File 'lib/windoo/objects/extension_attribute.rb', line 89

#extensionAttributeIdInteger

Returns The id number of this extension attribute in the Title Editor.

Returns:

  • (Integer)

    The id number of this extension attribute in the Title Editor



# File 'lib/windoo/objects/extension_attribute.rb', line 57

#keyString

Returns The name of the extension attribute as it appears in Jamf Pro NOTE: must be unique in the Title Editor AND Jamf Pro.

Returns:

  • (String)

    The name of the extension attribute as it appears in Jamf Pro NOTE: must be unique in the Title Editor AND Jamf Pro.



# File 'lib/windoo/objects/extension_attribute.rb', line 74

#softwareTitleIdInteger

Returns The id number of the title which uses this extension attribute.

Returns:

  • (Integer)

    The id number of the title which uses this extension attribute



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

#valueString

Returns The Base64 encoded script for this extension attribute.

Returns:

  • (String)

    The Base64 encoded script for this extension attribute



# File 'lib/windoo/objects/extension_attribute.rb', line 83

Class Method Details

.create(container: nil, **init_data) ⇒ Object

Override for APICollection.create to deal with raw scripts being passed in and converted to ‘values’



42
43
44
45
46
47
48
49
50
# File 'lib/windoo/objects/extension_attribute.rb', line 42

def self.create(container: nil, **init_data)
  if init_data[:script]
    require 'base64'
    init_data[:value] = Base64.encode64 init_data[:script]
    init_data.delete :script
  end

  super container: container, cnx: container.cnx, **init_data
end

Instance Method Details

#scriptString

Returns The script code for this extension attribute.

Returns:

  • (String)

    The script code for this extension attribute



112
113
114
115
116
117
# File 'lib/windoo/objects/extension_attribute.rb', line 112

def script
  return if value.to_s.empty?

  require 'base64'
  Base64.decode64 value
end

#script=(code) ⇒ void

This method returns an undefined value.

Parameters:

  • code (String)

    The script code for this extension attribute

Raises:

  • (ArgumentError)


121
122
123
124
125
126
# File 'lib/windoo/objects/extension_attribute.rb', line 121

def script=(code)
  raise ArgumentError, 'Code must be a string starting with #!' unless code.to_s.start_with?('#!')

  require 'base64'
  self.value = Base64.encode64(code)
end