Class: JSS::RestrictedSoftware

Inherits:
APIObject show all
Includes:
Creatable, Scopable, Sitable, Updatable
Defined in:
lib/jss/api_object/restricted_software.rb,
lib/jss.rb

Overview

Restricted Software items in the JSS.

See Also:

Constant Summary collapse

RSRC_BASE =

The base for REST resources of this class

'restrictedsoftware'.freeze
RSRC_LIST_KEY =

the hash key used for the JSON list output of all objects in the JSS

:restricted_software
RSRC_OBJECT_KEY =

The hash key used for the JSON object output. It's also used in various error messages

:restricted_software
VALID_DATA_KEYS =

these keys, as well as :id and :name, are present in valid API JSON data for this class

[:scope].freeze
SCOPE_TARGET_KEY =

Our scopes deal with computers

:computers
OBJECT_HISTORY_OBJECT_TYPE =

the object type for this object in the object history table. See APIObject#add_object_history_entry

5
SITE_SUBSET =

Where is the Site data in the API JSON?

:general

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ RestrictedSoftware

Instance Methods



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/jss/api_object/restricted_software.rb', line 70

def initialize(args = {})
  super args

  @init_data[:general] ||= {}
  @process_name = @init_data[:general][:process_name]
  @match_exact_process_name = @init_data[:general][:match_exact_process_name]
  @send_notification = @init_data[:general][:send_notification]
  @kill_process = @init_data[:general][:kill_process]
  @delete_executable = @init_data[:general][:delete_executable]
  @display_message = @init_data[:general][:display_message]
  @site = JSS::APIObject.get_name(@init_data[:general][:site])
  @site ||= 'None'
  @scope ||= JSS::Scopable::Scope.new SCOPE_TARGET_KEY, nil
end

Instance Attribute Details

#delete_executableBoolean Also known as: delete_executable?

Returns whether to delete the executable

Returns:

  • (Boolean)

    whether to delete the executable



59
60
61
# File 'lib/jss/api_object/restricted_software.rb', line 59

def delete_executable
  @delete_executable
end

#display_messageString

Returns message displayed to the user

Returns:

  • (String)

    message displayed to the user



62
63
64
# File 'lib/jss/api_object/restricted_software.rb', line 62

def display_message
  @display_message
end

#kill_processBoolean Also known as: kill_process?

Returns whether to kill the running process

Returns:

  • (Boolean)

    whether to kill the running process



56
57
58
# File 'lib/jss/api_object/restricted_software.rb', line 56

def kill_process
  @kill_process
end

#match_exact_process_nameBoolean Also known as: match_exact_process_name?

Returns whether to return match exact process name

Returns:

  • (Boolean)

    whether to return match exact process name



50
51
52
# File 'lib/jss/api_object/restricted_software.rb', line 50

def match_exact_process_name
  @match_exact_process_name
end

#need_to_updateBoolean (readonly) Originally defined in module Updatable

Returns do we have unsaved changes?

Returns:

  • (Boolean)

    do we have unsaved changes?

#process_nameString

Returns the process name

Returns:

  • (String)

    the process name



47
48
49
# File 'lib/jss/api_object/restricted_software.rb', line 47

def process_name
  @process_name
end

#scopeObject Originally defined in module Scopable

Attribtues

#send_notificationBoolean Also known as: send_notification?

Returns whether to send a notification

Returns:

  • (Boolean)

    whether to send a notification



53
54
55
# File 'lib/jss/api_object/restricted_software.rb', line 53

def send_notification
  @send_notification
end

#siteHash

Returns the :name and :id of the site for this machine

Returns:

  • (Hash)

    the :name and :id of the site for this machine



65
66
67
# File 'lib/jss/api_object/restricted_software.rb', line 65

def site
  @site
end

Instance Method Details

#clone(new_name, api: nil) ⇒ APIObject Originally defined in module Creatable

make a clone of this API object, with a new name. The class must be creatable

Parameters:

  • name (String)

    the name for the new object

  • api (JSS::APIConnection)

    the API in which to create the object Defaults to the API used to instantiate this object

Returns:

  • (APIObject)

    An uncreated clone of this APIObject with the given name

Raises:

#createObject



131
132
133
134
135
# File 'lib/jss/api_object/restricted_software.rb', line 131

def create
  raise JSS::MissingDataError, 'process_name must be set before creating' if @process_name.to_s.empty?
  raise JSS::AlreadyExistsError, "A #{RSRC_OBJECT_KEY} named #{@name} already exists in the JSS" if self.class.all_names(:refresh, api: @api).include? @name
  super
end

#name=(newname) ⇒ void Originally defined in module Updatable

This method returns an undefined value.

Change the name of this item Remember to #update to push changes to the server.

Parameters:

  • newname (String)

    the new name

Raises:

#parse_scopevoid Originally defined in module Scopable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Call this during initialization of objects that have a scope and the scope instance will be created from @init_data

#should_updatevoid Originally defined in module Scopable

This method returns an undefined value.

When the scope changes, it calls this to tell us that an update is needed.

#site_assigned?Boolean Originally defined in module Sitable

Does this object have a site assigned?

Returns:

  • (Boolean)

    Does this object have a site assigned?

#site_idInteger Originally defined in module Sitable

The id of the site for this object.

Returns:

  • (Integer)

    The id of the site for this object.

#site_nameString Also known as: site Originally defined in module Sitable

The name of the site for this object. For backward compatibility, this is aliased to just 'site'

Returns:

  • (String)

    The name of the site for this object.

#site_objectJSS::Site Originally defined in module Sitable

The JSS::Site instance for this object's site

Returns:

  • (JSS::Site)

    The JSS::Site instance for this object's site

#unset_sitevoid Originally defined in module Sitable

This method returns an undefined value.

Set the site to nothing

#updateObject



137
138
139
140
# File 'lib/jss/api_object/restricted_software.rb', line 137

def update
  raise JSS::MissingDataError, 'process_name must be set before updating' if @process_name.to_s.empty?
  super
end