lib/jss/api_object/creatable.rb
def create
      raise JSS::UnsupportedError, "Creating or editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless creatable?

      raise AlreadyExistsError, "This #{self.class::RSRC_OBJECT_KEY} already exists. Use #update to make changes." if @in_jss

      @api.post_rsrc(rest_rsrc, rest_xml) =~ %r{><id>(\d+)</id><}
      @id = Regexp.last_match(1).to_i
      @in_jss = true
      @need_to_update = false
      @rest_rsrc = "#{self.class::RSRC_BASE}/id/#{@id}"

      # clear any caches for this class
      # so they'll re-cache as needed
      @api.flushcache self.class::RSRC_LIST_KEY

      @id
    end
# Create a new object in the JSS.
#
# @param api[JSS::APIConnection] the API in which to create the object
#   Defaults to the API used to instantiate this object
#
# @return [Integer] the jss ID of the newly created object
#
Create a new object in the JSS.
Create a new object in the JSS .
def create
      raise JSS::UnsupportedError, "Creating or editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless creatable?
      raise AlreadyExistsError, "This #{self.class::RSRC_OBJECT_KEY} already exists. Use #update to make changes." if @in_jss
      @api.post_rsrc(rest_rsrc, rest_xml) =~ %r{><id>(\d+)</id><}
      @id = Regexp.last_match(1).to_i
      @in_jss = true
      @need_to_update = false
      @rest_rsrc = "#{self.class::RSRC_BASE}/id/#{@id}"
      @api.flushcache self.class::RSRC_LIST_KEY
      @id
    end
def create raise JSS :: UnsupportedError , "Creating or editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless creatable? raise AlreadyExistsError , "This #{self.class::RSRC_OBJECT_KEY} already exists. Use #update to make changes." if @in_jss @api . post_rsrc ( rest_rsrc , rest_xml ) =~ %r{ ><id>( \d +)</id>< } @id = Regexp . last_match ( 1 ) . to_i @in_jss = true @need_to_update = false @rest_rsrc = "#{self.class::RSRC_BASE}/id/#{@id}" @api . flushcache self . class :: RSRC_LIST_KEY @id end
Create a new object in the JSS.
Create a new object in the JSS .
# clear any caches for this class # so they'll re-cache as needed
the jss ID of the newly created object
the jss ID of the newly created object
Integer
api
the API in which to create the object Defaults to the API used to instantiate this object
the API in which to create the object Defaults to the API used to instantiate this object