ruby-jss 0.11.0a5 → 0.11.0a6

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.

Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +35 -29
  3. data/README.md +36 -48
  4. data/bin/cgrouper +1 -1
  5. data/bin/jamfHelperBackgrounder +1 -1
  6. data/bin/netseg-update +1 -1
  7. data/lib/jss.rb +1 -1
  8. data/lib/jss/api_connection.rb +1 -1
  9. data/lib/jss/api_object.rb +1 -1
  10. data/lib/jss/api_object/account.rb +1 -1
  11. data/lib/jss/api_object/advanced_search.rb +1 -1
  12. data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +1 -1
  13. data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +1 -1
  14. data/lib/jss/api_object/advanced_search/advanced_user_search.rb +1 -1
  15. data/lib/jss/api_object/building.rb +1 -1
  16. data/lib/jss/api_object/categorizable.rb +1 -1
  17. data/lib/jss/api_object/category.rb +1 -1
  18. data/lib/jss/api_object/computer.rb +6 -18
  19. data/lib/jss/api_object/computer_invitation.rb +1 -1
  20. data/lib/jss/api_object/creatable.rb +1 -1
  21. data/lib/jss/api_object/criteriable.rb +1 -1
  22. data/lib/jss/api_object/criteriable/criteria.rb +1 -1
  23. data/lib/jss/api_object/criteriable/criterion.rb +1 -1
  24. data/lib/jss/api_object/department.rb +1 -1
  25. data/lib/jss/api_object/distribution_point.rb +1 -1
  26. data/lib/jss/api_object/extendable.rb +1 -1
  27. data/lib/jss/api_object/extension_attribute.rb +1 -1
  28. data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +1 -1
  29. data/lib/jss/api_object/extension_attribute/mobile_device_extension_attribute.rb +1 -1
  30. data/lib/jss/api_object/extension_attribute/user_extension_attribute.rb +1 -1
  31. data/lib/jss/api_object/group.rb +1 -1
  32. data/lib/jss/api_object/group/computer_group.rb +1 -1
  33. data/lib/jss/api_object/group/mobile_device_group.rb +1 -1
  34. data/lib/jss/api_object/group/user_group.rb +1 -1
  35. data/lib/jss/api_object/ldap_server.rb +1 -1
  36. data/lib/jss/api_object/locatable.rb +1 -1
  37. data/lib/jss/api_object/management_history.rb +29 -17
  38. data/lib/jss/api_object/management_history/audit_event.rb +1 -0
  39. data/lib/jss/api_object/management_history/casper_imaging_log.rb +1 -0
  40. data/lib/jss/api_object/management_history/casper_remote_log.rb +1 -0
  41. data/lib/jss/api_object/management_history/computer_usage_log.rb +1 -0
  42. data/lib/jss/api_object/management_history/ebook.rb +1 -0
  43. data/lib/jss/api_object/management_history/hashlike.rb +24 -0
  44. data/lib/jss/api_object/management_history/mac_app_store_app.rb +1 -0
  45. data/lib/jss/api_object/management_history/mdm_command.rb +1 -0
  46. data/lib/jss/api_object/management_history/mobile_device_app.rb +2 -0
  47. data/lib/jss/api_object/management_history/policy_log.rb +1 -0
  48. data/lib/jss/api_object/management_history/screen_sharing_log.rb +1 -0
  49. data/lib/jss/api_object/management_history/user_location_change.rb +3 -0
  50. data/lib/jss/api_object/matchable.rb +1 -1
  51. data/lib/jss/api_object/mdm.rb +1 -1
  52. data/lib/jss/api_object/mobile_device.rb +10 -12
  53. data/lib/jss/api_object/mobile_device_application.rb +1 -1
  54. data/lib/jss/api_object/netboot_server.rb +1 -1
  55. data/lib/jss/api_object/network_segment.rb +1 -1
  56. data/lib/jss/api_object/osx_configuration_profile.rb +1 -1
  57. data/lib/jss/api_object/package.rb +1 -1
  58. data/lib/jss/api_object/patch.rb +1 -1
  59. data/lib/jss/api_object/patch_policy.rb +1 -1
  60. data/lib/jss/api_object/peripheral.rb +1 -1
  61. data/lib/jss/api_object/peripheral_type.rb +1 -1
  62. data/lib/jss/api_object/policy.rb +1 -1
  63. data/lib/jss/api_object/purchasable.rb +1 -1
  64. data/lib/jss/api_object/removable_macaddr.rb +1 -1
  65. data/lib/jss/api_object/scopable.rb +1 -1
  66. data/lib/jss/api_object/scopable/scope.rb +1 -1
  67. data/lib/jss/api_object/script.rb +1 -1
  68. data/lib/jss/api_object/self_servable.rb +1 -1
  69. data/lib/jss/api_object/self_servable/icon.rb +1 -1
  70. data/lib/jss/api_object/sitable.rb +1 -1
  71. data/lib/jss/api_object/site.rb +1 -1
  72. data/lib/jss/api_object/software_update_server.rb +1 -1
  73. data/lib/jss/api_object/updatable.rb +1 -1
  74. data/lib/jss/api_object/uploadable.rb +1 -1
  75. data/lib/jss/api_object/user.rb +1 -1
  76. data/lib/jss/api_object/vppable.rb +1 -1
  77. data/lib/jss/api_object/webhook.rb +1 -1
  78. data/lib/jss/client.rb +1 -1
  79. data/lib/jss/compatibility.rb +1 -1
  80. data/lib/jss/composer.rb +1 -1
  81. data/lib/jss/configuration.rb +1 -1
  82. data/lib/jss/db_connection.rb +1 -1
  83. data/lib/jss/exceptions.rb +1 -1
  84. data/lib/jss/ruby_extensions.rb +1 -1
  85. data/lib/jss/ruby_extensions/array.rb +1 -1
  86. data/lib/jss/ruby_extensions/filetest.rb +1 -1
  87. data/lib/jss/ruby_extensions/hash.rb +1 -1
  88. data/lib/jss/ruby_extensions/ipaddr.rb +1 -1
  89. data/lib/jss/ruby_extensions/pathname.rb +1 -1
  90. data/lib/jss/ruby_extensions/string.rb +1 -1
  91. data/lib/jss/ruby_extensions/time.rb +1 -1
  92. data/lib/jss/server.rb +1 -1
  93. data/lib/jss/utility.rb +1 -1
  94. data/lib/jss/validate.rb +1 -1
  95. data/lib/jss/version.rb +2 -2
  96. metadata +3 -2
data/lib/jss.rb CHANGED
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
  ###
3
3
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
4
4
  ### with the following modification; you may not use this file except in
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -82,24 +82,12 @@ module JSS
82
82
  # which removes the mdm profile, but also makes the machine unmanged by the
83
83
  # JSS, setting the management acct to nil, and requring re-enrollment.
84
84
  #
85
- # === Computer History
85
+ # === Management History & Logs
86
86
  #
87
- # Computer instances can now retrieve their management history from the JSS.
88
- #
89
- # The full history data is available from the {#history} method, but beware that
90
- # it is very large.
91
- #
92
- # Subsets of that history have their own methods, which are faster and only retrieve
93
- # the subset requested. See {#usage_logs}, {#audits}, {#policy_los},
94
- # {#completed_policies}, {#failed_polices}, {#casper_remote_logs},
95
- # {#screen_sharing_logs}, {#casper_imaging_logs}, {#commands},
96
- # {#user_location_history},and {#app_store_app_history}
97
- #
98
- # When any of the history methods is used the first time, the data is read
99
- # from the API and cached internally, and that data is
100
- # used for all future calls.. To re-read the data from the API and re-cache it,
101
- # provide any non-false parameter to the subset methods , or `refresh: true`
102
- # to the main {#history} method.
87
+ # Computer Management History and logs can now be retrieved both from a
88
+ # Computer instance, and directly via class methods without fetching an
89
+ # instance. This is handled by the mixed-in {JSS::ManagementHistory} module,
90
+ # Q.V. for details.
103
91
  #
104
92
  # === Appication Usage History
105
93
  #
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Pixar
1
+ # Copyright 2018 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Pixar
1
+ # Copyright 2018 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- ### Copyright 2017 Pixar
1
+ ### Copyright 2018 Pixar
2
2
 
3
3
  ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -32,9 +32,9 @@ module JSS
32
32
  # Objects mixing in this module have 'management history' in the JSS, which at
33
33
  # this point is Computers and MobileDevices
34
34
  #
35
- # *Important:* this is 'management history', i.e. the history
36
- # of mdm commands, locations, apps, and other events that are part of
37
- # management and inventory collection.
35
+ # *Important:* this is 'management history', i.e. the history and logs
36
+ # of mdm commands, locations, apps, policies, and other events that are part
37
+ # of management and inventory collection.
38
38
  #
39
39
  # When viewing the details page for a computer or mobile device in the
40
40
  # Web UI, this is the data visible in the 'History' pane of the page.
@@ -52,31 +52,42 @@ module JSS
52
52
  # instance methods that are wrappers around the class methods. The methods
53
53
  # have the same names, but of course the class methods require arguments
54
54
  # specifying the target for which to retrieve data, and which API connection
55
- # to use.
55
+ # to use (defaulting to the currently active connection).
56
56
  #
57
57
  # == Raw data versus processed data & event object classes
58
58
  #
59
59
  # The primary data-retrieval method for management history data is
60
60
  # {JSS::ManagementHistory.management_history}. This method returns the raw
61
- # JSON data from the API, parsed into a ruby Hash.
61
+ # JSON data from the API, parsed into a Ruby Hash. If you don't specify a
62
+ # subset, the data returned can be very large.
62
63
  #
63
- # This data is somewhat inconsistent in it's structure and content across the
64
- # different types of history events, but you're welcome to use it if needed.
64
+ # This data is somewhat inconsistent in its structure and content across the
65
+ # different subsets of history events, but you're welcome to use it if needed.
65
66
  #
66
67
  # To provide a more consistent and ruby-like interface to the history events,
67
68
  # the remaining methods, which only return subsets of the full dataset, will
68
69
  # return Arrays of instances of the classes defined in this module.
69
70
  #
70
- # For example, the {JSS::ManagementHistory.audit_history} method returns an
71
- # Array of JSS::ManagementHistory::AuditEvent instances, and the
72
- # {JSS::ManagementHistory.completed_policies} gives an Array of
73
- # JSS::ManagementHistory::PolicyLog objects. These objects are read-only
74
- # and provide access to their values via attribute-style methods.
71
+ # For example, the {JSS::MobileDevice.audit_history} method returns an Array
72
+ # of JSS::ManagementHistory::AuditEvent instances, and the
73
+ # {JSS::Computer.completed_policies} gives an Array of
74
+ # JSS::ManagementHistory::PolicyLog objects.
75
+ #
76
+ # These objects are read-only and provide access to their values via both
77
+ # attribute-style methods, and hash-like keys, similar to how OpenStruct
78
+ # objects do.
79
+ # This means that
80
+ # `some_log_event.date_time`
81
+ # and
82
+ # `some_log_event[:date_time]`
83
+ # are identical.
84
+ # This *may* help with some backward-compatibility issues.
85
+ #
75
86
  #
76
87
  # NOTE: History queries from the API are *not* cached in ruby-jss, like the
77
- # APIObject.all data is - it is queried anew every time. For this reason, you
78
- # are encouraged to store the results of these methods in variables for later
79
- # use if needed.
88
+ # APIObject.all data is - instead it is queried anew every time. For this reason,
89
+ # you are encouraged to store the results of these methods in variables for
90
+ # later use if needed.
80
91
  #
81
92
  module ManagementHistory
82
93
 
@@ -177,7 +188,7 @@ module JSS
177
188
  #
178
189
  def management_history(ident, subset = nil, api: JSS.api)
179
190
  id = valid_id ident, api: api
180
- raise JSS::NoSuchItemError, "No #{RSRC_OBJECT_KEY} matches identifier: #{ident}" unless id
191
+ raise JSS::NoSuchItemError, "No #{self::RSRC_OBJECT_KEY} matches identifier: #{ident}" unless id
181
192
 
182
193
  if self == JSS::Computer
183
194
  @hist_subsets ||= HIST_COMPUTER_SUBSETS
@@ -852,6 +863,7 @@ module JSS
852
863
 
853
864
  end # module JSS
854
865
 
866
+ require 'jss/api_object/management_history/hashlike'
855
867
  require 'jss/api_object/management_history/audit_event'
856
868
  require 'jss/api_object/management_history/casper_imaging_log'
857
869
  require 'jss/api_object/management_history/casper_remote_log'
@@ -17,6 +17,7 @@ module JSS
17
17
  :username,
18
18
  :date_time_epoch
19
19
  )
20
+ include JSS::ManagementHistory::HashLike
20
21
 
21
22
  # @!attribute [r] event
22
23
  # @return [String] The description of the event.
@@ -16,6 +16,7 @@ module JSS
16
16
  :status,
17
17
  :date_time_epoch
18
18
  )
19
+ include JSS::ManagementHistory::HashLike
19
20
 
20
21
  # @!attribute [r] status
21
22
  # @return [String] The status of the event.
@@ -16,6 +16,7 @@ module JSS
16
16
  :status,
17
17
  :date_time_epoch
18
18
  )
19
+ include JSS::ManagementHistory::HashLike
19
20
 
20
21
  # @!attribute [r] status
21
22
  # @return [String] The status of the event.
@@ -17,6 +17,7 @@ module JSS
17
17
  :username,
18
18
  :date_time_epoch
19
19
  )
20
+ include JSS::ManagementHistory::HashLike
20
21
 
21
22
  # @!attribute [r] event
22
23
  # @return [String] The description of the event.
@@ -23,6 +23,7 @@ module JSS
23
23
  :management_status,
24
24
  :source
25
25
  )
26
+ include JSS::ManagementHistory::HashLike
26
27
 
27
28
  # @!attribute [r] title
28
29
  # @return [String] The name of the ebook.
@@ -0,0 +1,24 @@
1
+ #
2
+ module JSS
3
+
4
+ #
5
+ module ManagementHistory
6
+
7
+ # This is mixed in to the history event classes to
8
+ # provide hash-like access to their attributes, so that
9
+ # `some_event[:date_time]`
10
+ # works the same as
11
+ # `some_event.date_time`
12
+ # just as with OpenStruct objects
13
+ #
14
+ module HashLike
15
+
16
+ def [](attr)
17
+ self.send attr.to_sym
18
+ end
19
+
20
+ end # HashLike
21
+
22
+ end # module ManagementHistory
23
+
24
+ end # module JSS
@@ -23,6 +23,7 @@ module JSS
23
23
  :last_update_epoch,
24
24
  :size_mb
25
25
  )
26
+ include JSS::ManagementHistory::HashLike
26
27
 
27
28
  # @!attribute [r] name
28
29
  # @return [String] the name of the app.
@@ -25,6 +25,7 @@ module JSS
25
25
  :completed_epoch,
26
26
  :last_push_epoch
27
27
  )
28
+ include JSS::ManagementHistory::HashLike
28
29
 
29
30
  def initialize(args = {})
30
31
  args[:completed_epoch] ||= args[:date_time_completed_epoch]
@@ -25,6 +25,8 @@ module JSS
25
25
  :dynamic_size
26
26
  )
27
27
 
28
+ include JSS::ManagementHistory::HashLike
29
+
28
30
  # @!attribute [r] name
29
31
  # @return [String] the name of the app.
30
32
 
@@ -19,6 +19,7 @@ module JSS
19
19
  :date_completed_epoch,
20
20
  :status
21
21
  )
22
+ include JSS::ManagementHistory::HashLike
22
23
 
23
24
  def initialize(args = {})
24
25
  # we want the status as a Symbol