Method: JSS::Updatable#name=

Defined in:
lib/jss-api/api_object/updatable.rb

#name=(newname) ⇒ void

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:



91
92
93
94
95
96
97
98
99
# File 'lib/jss-api/api_object/updatable.rb', line 91

def name= (newname)
  raise JSS::UnsupportedError, "Editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless UPDATABLE
  return nil if @name == newname
  raise JSS::InvalidDataError, "Names can't be empty!" if newname.to_s.empty?
  raise JSS::AlreadyExistsError, "A #{self.class::RSRC_OBJECT_KEY} named '#{newname}' already exsists in the JSS" if self.class.all_names(:refresh).include? newname
  @name = newname
  @rest_rsrc = "#{self.class::RSRC_BASE}/name/#{URI.escape @name}" if @rest_rsrc.include? '/name/'
  @need_to_update = true
end