ruby-jss 1.1.0b2 → 1.1.0b3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ruby-jss might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a50ff471b21545912900e60e06df0db44afb07369e140af205f13c3cc2bfad40
4
- data.tar.gz: 699823c8d74f492ee99f4c1cd742783c9a033de3457ac4f6740aa777301aafd4
3
+ metadata.gz: c93768b14659a35387a451d6b310ada61703377b15bd18336430a5ba22b092d0
4
+ data.tar.gz: 1fffb42782534b0cd38799d549911332da08363606864ef0a5e178f657b8f1a3
5
5
  SHA512:
6
- metadata.gz: a8af9b0bb6b77cfc377bbd0d83759e8d4ada3868b2f13a72c4cc9820d22a7582e82e4fe118217f6bc251eb386c2a3ddbd2434e4fd9f95e06ae2a4492c5edab99
7
- data.tar.gz: f428d23ab93e6dc3d6f279353d90299b1d64fc41093bcaeaf06d15baffa6abf931e6b76c2491ae4d53eb0747ecbdcd1a60e9b670a6f91d9e33493838c038e593
6
+ metadata.gz: 565603a221d5e5b17595008b0ad385b5880930802897586d7276e22cb7abbcfd8bac24971e6842fc8ebf6d52434db6cdc61f05f4efdaa661e7338fc430379db6
7
+ data.tar.gz: ad6b0d25702b25e9058ee6201cde765b1f78944a6cd8f9be7cd43683939c5661a2a82daf04146787cf325f650de573f7c33f1fdd6dc371312ac966788152077c
@@ -917,49 +917,25 @@ module JSS
917
917
  @my_distribution_point
918
918
  end
919
919
 
920
- # All NetworkSegments in this jss as IPAddr object Ranges representing the
921
- # Segment, e.g. with starting = 10.24.9.1 and ending = 10.24.15.254
922
- # the range looks like:
923
- # <IPAddr: IPv4:10.24.9.1/255.255.255.255>..#<IPAddr: IPv4:10.24.15.254/255.255.255.255>
920
+ # @deprecated
924
921
  #
925
- # Using the #include? method on those Ranges is very useful.
926
- #
927
- # @param refresh[Boolean] should the data be re-queried?
928
- #
929
- # @return [Hash{Integer => Range}] the network segments as IPv4 address Ranges
922
+ # @see {JSS::NetworkSegment.network_ranges}
930
923
  #
931
924
  def network_ranges(refresh = false)
932
- @network_ranges = nil if refresh
933
- return @network_ranges if @network_ranges
934
- @network_ranges = {}
935
- JSS::NetworkSegment.all(refresh, api: self).each do |ns|
936
- @network_ranges[ns[:id]] = IPAddr.new(ns[:starting_address])..IPAddr.new(ns[:ending_address])
937
- end
938
- @network_ranges
925
+ JSS::NetworkSegment.network_ranges refresh, api: self
939
926
  end # def network_segments
940
927
 
941
- # Find the ids of the network segments that contain a given IP address.
942
- #
943
- # Even tho IPAddr.include? will take a String or an IPAddr
944
- # I convert the ip to an IPAddr so that an exception will be raised if
945
- # the ip isn't a valid ip.
946
- #
947
- # @param ip[String, IPAddr] the IP address to locate
948
- #
949
- # @param refresh[Boolean] should the data be re-queried?
928
+ # @deprecated
950
929
  #
951
- # @return [Array<Integer>] the ids of the NetworkSegments containing the given ip
930
+ # @see {JSS::NetworkSegment.network_segments_for_ip}
952
931
  #
953
- def network_segments_for_ip(ip)
954
- ok_ip = IPAddr.new(ip)
955
- matches = []
956
- network_ranges.each { |id, subnet| matches << id if subnet.include?(ok_ip) }
957
- matches
932
+ def network_segments_for_ip(ip, refresh = false)
933
+ JSS::NetworkSegment.network_segments_for_ip ip, refresh, api: self
958
934
  end
959
935
 
960
- # Find the current network segment ids for the machine running this code
936
+ # @deprecated
961
937
  #
962
- # @return [Array<Integer>] the NetworkSegment ids for this machine right now.
938
+ # @see {JSS::NetworkSegment.my_network_segments}
963
939
  #
964
940
  def my_network_segments
965
941
  network_segments_for_ip JSS::Client.my_ip_address
@@ -503,8 +503,8 @@ module JSS
503
503
  raise "Subset must be one of :#{MGMT_DATA_SUBSETS.join ', :'}" unless MGMT_DATA_SUBSETS.include? subset
504
504
  subset_rsrc = MGMT_DATA_RSRC + "/id/#{id}/subset/#{subset}"
505
505
  subset_data = api.get_rsrc(subset_rsrc)[MGMT_DATA_KEY]
506
- return subset_data unless only
507
- subset_data.map { |d| d[only] }
506
+ return subset_data[subset] unless only
507
+ subset_data[subset].map { |d| d[only] }
508
508
  end
509
509
  private_class_method :management_data_subset
510
510
 
@@ -556,6 +556,9 @@ module JSS
556
556
  # @return [Boolean] doesit support MDM?
557
557
  attr_reader :mdm_capable
558
558
 
559
+ # @return [Hash] some MDM status details in general
560
+ attr_reader :management_status
561
+
559
562
  # @return [Array] user accts that support MDM?
560
563
  # NOTE: This suffers from the JSON-Hash-treated-like_XML-Array-loses-data
561
564
  # bug and only shows the last listed user, cuz it comes from the API
@@ -793,6 +796,8 @@ module JSS
793
796
 
794
797
  @configuration_profiles = @init_data[:configuration_profiles]
795
798
 
799
+ @management_status = @init_data[:general][:management_status]
800
+
796
801
  @groups_accounts = @init_data[:groups_accounts]
797
802
  @hardware = @init_data[:hardware]
798
803
  @peripherals = @init_data[:peripherals]
@@ -177,6 +177,7 @@ module JSS
177
177
  ###
178
178
  def self.validate_ip_range(startip, endip)
179
179
  return nil if IPAddr.new(startip.to_s) <= IPAddr.new(endip.to_s)
180
+
180
181
  raise JSS::InvalidDataError, "Starting IP #{startip} is higher than ending ip #{endip} "
181
182
  end
182
183
 
@@ -195,29 +196,60 @@ module JSS
195
196
  ### @return [Array<Integer>] the ids of the NetworkSegments containing the given ip
196
197
  ###
197
198
  def self.network_segments_for_ip(ip, refresh = false, api: JSS.api)
198
- api.network_segments_for_ip ip, refresh
199
+ ok_ip = IPAddr.new(ip)
200
+ matches = []
201
+ network_ranges.each { |id, subnet| matches << id if subnet.include?(ok_ip) }
202
+ matches
199
203
  end
200
204
 
201
205
  # @deprecated use network_segments_for_ip
202
- # Backward compatibility
206
+ # Here for Backward compatibility
203
207
  def self.network_segment_for_ip(ip, api: JSS.api)
204
208
  network_segments_for_ip(ip, api: api)
205
209
  end
206
210
 
207
211
  ### Find the current network segment ids for the machine running this code
208
212
  ###
209
- ### @return [Array<Integer>] the NetworkSegment ids for this machine right now.
213
+ ### @return [Array<Integer>] the NetworkSegment ids for this machine right now.
210
214
  ###
211
- def self.my_network_segments(api: JSS.api)
212
- network_segment_for_ip JSS::Client.my_ip_address, api: api
215
+ def self.my_network_segments(refresh = false, names: false, api: JSS.api)
216
+ ids = network_segments_for_ip JSS::Client.my_ip_address, refresh, api: api
217
+ return ids unless names
218
+
219
+ ids_to_names = map_all_ids_to :name
220
+ ids.map { |id| ids_to_names[id] }
213
221
  end
214
222
 
215
223
  # @deprecated use my_network_segments
216
- # Backward compatibility
224
+ # Here for backward compatibility
217
225
  def self.my_network_segment(api: JSS.api)
218
226
  my_network_segments api: api
219
227
  end
220
228
 
229
+ # All NetworkSegments in this jss as IPAddr object Ranges representing the
230
+ # Segment, e.g. with starting = 10.24.9.1 and ending = 10.24.15.254
231
+ # the range looks like:
232
+ # <IPAddr: IPv4:10.24.9.1/255.255.255.255>..#<IPAddr: IPv4:10.24.15.254/255.255.255.255>
233
+ #
234
+ # Using the #include? method on those Ranges is very useful.
235
+ #
236
+ # @param refresh[Boolean] should the data be re-queried?
237
+ #
238
+ # @param api[JSS::APIConnection] the API to query
239
+ #
240
+ # @return [Hash{Integer => Range}] the network segments as IPv4 address Ranges
241
+ # keyed by id
242
+ #
243
+ def self.network_ranges(refresh = false, api: JSS.api)
244
+ @network_ranges = nil if refresh
245
+ return @network_ranges if @network_ranges
246
+ @network_ranges = {}
247
+ all(refresh, api: api).each do |ns|
248
+ @network_ranges[ns[:id]] = IPAddr.new(ns[:starting_address])..IPAddr.new(ns[:ending_address])
249
+ end
250
+ @network_ranges
251
+ end # def network_segments
252
+
221
253
  ### Attributes
222
254
  #####################################
223
255
 
@@ -307,7 +307,8 @@ module JSS
307
307
  params[:source_id] ||= params[:source]
308
308
 
309
309
  # if given a source name, this converts it to an id
310
- params[:source_id] = JSS::PatchSource.valid_id params[:source_id]
310
+ params[:source_id] = JSS::PatchInternalSource.valid_id params[:source_id]
311
+ params[:source_id] ||= JSS::PatchExternalSource.valid_id params[:source_id]
311
312
 
312
313
  # build a possible source_name_id
313
314
  params[:source_name_id] ||= "#{params[:source_id]}-#{params[:name_id]}"
@@ -191,7 +191,7 @@ module JSS
191
191
  after: 'After'
192
192
  }.freeze
193
193
 
194
- PRINTER_ACTIIONS = {
194
+ PRINTER_ACTIONS = {
195
195
  map: 'install',
196
196
  unmap: 'uninstall'
197
197
  }.freeze
@@ -1051,7 +1051,11 @@ module JSS
1051
1051
  # @return [Pathname] The path to search for
1052
1052
  #
1053
1053
  def search_by_path
1054
- Pathname.new @files_processes[:search_by_path]
1054
+ if @files_processes[:search_by_path].nil?
1055
+ return nil
1056
+ else
1057
+ Pathname.new @files_processes[:search_by_path]
1058
+ end
1055
1059
  end
1056
1060
 
1057
1061
  # @return [Boolean] Should the searched-for path be deleted if found?
@@ -1300,16 +1304,22 @@ module JSS
1300
1304
  @dock_items.map { |p| p[:name] }
1301
1305
  end
1302
1306
 
1303
- ###### Printers
1304
-
1305
1307
  # @return [Array] the id's of the printers handled by the policy
1306
1308
  def printer_ids
1307
- @printers.map { |p| p[:id] }
1309
+ begin
1310
+ @printers.map { |p| p[:id] }
1311
+ rescue TypeError
1312
+ return []
1313
+ end
1308
1314
  end
1309
-
1315
+
1310
1316
  # @return [Array] the names of the printers handled by the policy
1311
1317
  def printer_names
1312
- @printers.map { |p| p[:name] }
1318
+ begin
1319
+ @printers.map { |p| p[:name] }
1320
+ rescue TypeError
1321
+ return []
1322
+ end
1313
1323
  end
1314
1324
 
1315
1325
  ###### Actions
@@ -26,7 +26,7 @@
26
26
  ###
27
27
  module JSS
28
28
 
29
- ### The version of the JSS ruby gem
30
- VERSION = '1.1.0b2'.freeze
29
+ ### The version of ruby-jss
30
+ VERSION = '1.1.0b3'.freeze
31
31
 
32
32
  end # module
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-jss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0b2
4
+ version: 1.1.0b3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Lasell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-01 00:00:00.000000000 Z
12
+ date: 2019-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: plist