lib/jss/api_object/extension_attribute.rb in ruby-jss-0.9.2 vs lib/jss/api_object/extension_attribute.rb in ruby-jss-0.10.0a1
- old
+ new
@@ -199,19 +199,19 @@
###
### @see JSS::APIObject#delete
###
def delete
- orig_open_timeout = JSS.api_connection.cnx.options[:open_timeout]
- orig_timeout = JSS.api_connection.cnx.options[:timeout]
- JSS.api_connection.timeout = orig_timeout + 1800
- JSS.api_connection.open_timeout = orig_open_timeout + 1800
+ orig_open_timeout = @api.cnx.options[:open_timeout]
+ orig_timeout = @api.cnx.options[:timeout]
+ @api.timeout = orig_timeout + 1800
+ @api.open_timeout = orig_open_timeout + 1800
begin
super
ensure
- JSS.api_connection.timeout = orig_timeout
- JSS.api_connection.open_timeout = orig_open_timeout
+ @api.timeout = orig_timeout
+ @api.open_timeout = orig_open_timeout
end
end
###
### Change the description of this EA
@@ -331,11 +331,11 @@
raise JSS::NoSuchItemError, "EA Not In JSS! Use #create to create this #{self.class::RSRC_OBJECT_KEY}." unless @in_jss
raise JSS::InvalidDataError, "Invalid search_type, see JSS::Criteriable::Criterion::SEARCH_TYPES" unless JSS::Criteriable::Criterion::SEARCH_TYPES.include? search_type.to_s
begin
search_class = self.class::TARGET_CLASS::SEARCH_CLASS
- acs = search_class.new :id => :new, :name => "JSSgem-EA-#{Time.now.to_jss_epoch}-result-search"
+ acs = search_class.new api: @api, :id => :new, :name => "ruby-jss-EA-result-search-#{Time.now.to_jss_epoch}"
acs.display_fields = [@name]
crit_list = [JSS::Criteriable::Criterion.new(:and_or => "and", :name => @name, :search_type => search_type.to_s, :value => desired_value)]
acs.criteria = JSS::Criteriable::Criteria.new crit_list
acs.create :get_results
@@ -385,15 +385,15 @@
###
### @see JSS::AdvancedUserSearch
###
def latest_values
raise JSS::NoSuchItemError, "EA Not In JSS! Use #create to create this #{self.class::RSRC_OBJECT_KEY}." unless @in_jss
- tmp_advsrch = "JSSgem-EA-#{Time.now.to_jss_epoch}-latest-search"
+ tmp_advsrch = "ruby-jss-EA-latest-search-#{Time.now.to_jss_epoch}"
begin
search_class = self.class::TARGET_CLASS::SEARCH_CLASS
- acs = search_class.new :id => :new, :name => tmp_advsrch
+ acs = search_class.new id: :new, name: tmp_advsrch, api: @api
acs.display_fields = self.class::TARGET_CLASS == JSS::User ? [@name, USERNAME_FIELD] : [@name, USERNAME_FIELD, LAST_RECON_FIELD]
# search for 'Username like "" ' because all searchable object classes have a "Username" value
crit = JSS::Criteriable::Criterion.new(:and_or => "and", :name => "Username", :search_type => "like", :value => '')
# crit = self.class::ALL_TARGETS_CRITERION
@@ -413,11 +413,14 @@
results << {:id => i[:id], :name => i[:name], :username => i[USERNAME_FIELD_SYM] , :value => value, :as_of => as_of }
end #acs.search_results.each
ensure
- acs.delete
- self.class::TARGET_CLASS::SEARCH_CLASS.new(:name => tmp_advsrch).delete if self.class::TARGET_CLASS::SEARCH_CLASS.all_names(:refresh).include? tmp_advsrch
+ if defined? acs
+ acs.delete
+ else
+ search_class.fetch(:name => tmp_advsrch, api: @api).delete if search_class.all_names(:refresh, api: @api).include? tmp_advsrch
+ end
end
results
end