ruby-jss 4.2.0b2 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +25 -7
  3. data/README-2.0.0.md +19 -8
  4. data/README.md +43 -30
  5. data/lib/jamf/api/classic/api_objects/patch_title.rb +0 -2
  6. data/lib/jamf/api/jamf_pro/api_objects/api_client.rb +3 -0
  7. data/lib/jamf/api/jamf_pro/api_objects/api_role.rb +3 -0
  8. data/lib/jamf/api/jamf_pro/api_objects/j_package.rb +307 -119
  9. data/lib/jamf/api/jamf_pro/api_objects/managed_software_updates/plan.rb +237 -0
  10. data/lib/jamf/api/jamf_pro/api_objects/managed_software_updates.rb +291 -0
  11. data/lib/jamf/api/jamf_pro/base_classes/oapi_object.rb +8 -0
  12. data/lib/jamf/api/jamf_pro/mixins/collection_resource.rb +23 -3
  13. data/lib/jamf/api/jamf_pro/mixins/filterable.rb +8 -0
  14. data/lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb +17 -3
  15. data/lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb +2 -0
  16. data/lib/jamf/api/jamf_pro/mixins/prestage.rb +3 -0
  17. data/lib/jamf/api/jamf_pro/oapi_schemas/account_group.rb +123 -0
  18. data/lib/jamf/api/jamf_pro/oapi_schemas/account_preferences_v1.rb +105 -0
  19. data/lib/jamf/api/jamf_pro/oapi_schemas/assign_remove_profile_response_sync_state.rb +112 -0
  20. data/lib/jamf/api/jamf_pro/oapi_schemas/auth_account_v1.rb +159 -0
  21. data/lib/jamf/api/jamf_pro/oapi_schemas/authentication_type.rb +97 -0
  22. data/lib/jamf/api/jamf_pro/oapi_schemas/{device_enrollment_disown_body.rb → available_updates.rb} +14 -10
  23. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_application.rb +124 -0
  24. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_attachment.rb +102 -0
  25. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_certificate.rb +151 -0
  26. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_configuration_profile.rb +118 -0
  27. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching.rb +372 -0
  28. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching_alert.rb +120 -0
  29. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching_cache_detail.rb +97 -0
  30. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching_data_migration_error.rb +98 -0
  31. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching_data_migration_error_user_info.rb +89 -0
  32. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching_parent.rb +131 -0
  33. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching_parent_alert.rb +105 -0
  34. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching_parent_capabilities.rb +124 -0
  35. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching_parent_details.rb +118 -0
  36. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_content_caching_parent_local_network.rb +97 -0
  37. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_disk.rb +143 -0
  38. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_disk_encryption.rb +120 -0
  39. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_extension_attribute.rb +175 -0
  40. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_font.rb +93 -0
  41. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_general.rb +244 -0
  42. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_hardware.rb +264 -0
  43. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_ibeacon.rb +81 -0
  44. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_inventory.rb +276 -0
  45. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_inventory_file_vault.rb +127 -0
  46. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_licensed_software.rb +88 -0
  47. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_local_user_account.rb +196 -0
  48. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_mdm_capability.rb +88 -0
  49. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_operating_system.rb +148 -0
  50. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_package_receipts.rb +97 -0
  51. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_partition.rb +145 -0
  52. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_partition_encryption.rb +94 -0
  53. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_partition_file_vault2_state.rb +97 -0
  54. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_plugin.rb +93 -0
  55. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_prestage_v3.rb +129 -0
  56. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_printer.rb +99 -0
  57. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_purchase.rb +158 -0
  58. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_remote_management.rb +88 -0
  59. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_section.rb +109 -0
  60. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_security.rb +193 -0
  61. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_service.rb +81 -0
  62. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_software_update.rb +93 -0
  63. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_storage.rb +90 -0
  64. data/lib/jamf/api/jamf_pro/oapi_schemas/computer_user_and_location.rb +131 -0
  65. data/lib/jamf/api/jamf_pro/oapi_schemas/dss_declaration.rb +111 -0
  66. data/lib/jamf/api/jamf_pro/oapi_schemas/dss_declarations.rb +88 -0
  67. data/lib/jamf/api/jamf_pro/oapi_schemas/enrollment_method.rb +97 -0
  68. data/lib/jamf/api/jamf_pro/oapi_schemas/group_membership.rb +94 -0
  69. data/lib/jamf/api/jamf_pro/oapi_schemas/inventory_preload_extension_attribute.rb +89 -0
  70. data/lib/jamf/api/jamf_pro/oapi_schemas/location_information.rb +146 -0
  71. data/lib/jamf/api/jamf_pro/oapi_schemas/{package_manifest.rb → location_information_v2.rb} +35 -37
  72. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_plan.rb +181 -0
  73. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_plan_event_store.rb +85 -0
  74. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_plan_group_post.rb +99 -0
  75. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_plan_post.rb +98 -0
  76. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_plan_post_response.rb +100 -0
  77. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_plan_toggle.rb +115 -0
  78. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_plan_toggle_status.rb +169 -0
  79. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_plan_toggle_status_wrapper.rb +91 -0
  80. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_plans.rb +102 -0
  81. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_status.rb +173 -0
  82. data/lib/jamf/api/jamf_pro/oapi_schemas/managed_software_update_statuses.rb +102 -0
  83. data/lib/jamf/api/jamf_pro/oapi_schemas/mobile_device_prestage_name_v2.rb +94 -0
  84. data/lib/jamf/api/jamf_pro/oapi_schemas/mobile_device_prestage_names_v2.rb +118 -0
  85. data/lib/jamf/api/jamf_pro/oapi_schemas/plan_configuration_post.rb +142 -0
  86. data/lib/jamf/api/jamf_pro/oapi_schemas/plan_device.rb +105 -0
  87. data/lib/jamf/api/jamf_pro/oapi_schemas/plan_device_post.rb +97 -0
  88. data/lib/jamf/api/jamf_pro/oapi_schemas/plan_device_response.rb +96 -0
  89. data/lib/jamf/api/jamf_pro/oapi_schemas/plan_group_post.rb +96 -0
  90. data/lib/jamf/api/jamf_pro/oapi_schemas/plan_search_results.rb +89 -0
  91. data/lib/jamf/api/jamf_pro/oapi_schemas/plan_status.rb +127 -0
  92. data/lib/jamf/api/jamf_pro/oapi_schemas/{device_enrollment_prestage.rb → prestage_purchasing_information.rb} +51 -88
  93. data/lib/jamf/api/jamf_pro/oapi_schemas/prestage_purchasing_information_v2.rb +174 -0
  94. data/lib/jamf/api/jamf_pro/oapi_schemas/prestage_scope_assignment_v2.rb +94 -0
  95. data/lib/jamf/api/jamf_pro/oapi_schemas/v1_site.rb +91 -0
  96. data/lib/jamf/api/jamf_pro/oapi_schemas.rb +24 -1
  97. data/lib/jamf/composer.rb +114 -107
  98. data/lib/jamf/oapi_validate.rb +1 -0
  99. data/lib/jamf/version.rb +1 -1
  100. data/test/bin/runtests +2 -2
  101. data/test/lib/jamf_test/collection_tests.rb +10 -2
  102. data/test/tests/computer_group.rb +29 -12
  103. data/test/tests/{jp_building.rb → j_building.rb} +2 -2
  104. data/test/tests/j_package.rb +47 -0
  105. metadata +87 -8
@@ -0,0 +1,174 @@
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
+ # with the following modification; you may not use this file except in
5
+ # compliance with the Apache License and the following modification to it:
6
+ # Section 6. Trademarks. is deleted and replaced with:
7
+ #
8
+ # 6. Trademarks. This License does not grant permission to use the trade
9
+ # names, trademarks, service marks, or product names of the Licensor
10
+ # and its affiliates, except as required to comply with Section 4(c) of
11
+ # the License and to reproduce the content of the NOTICE file.
12
+ #
13
+ # You may obtain a copy of the Apache License at
14
+ #
15
+ # http://www.apache.org/licenses/LICENSE-2.0
16
+ #
17
+ # Unless required by applicable law or agreed to in writing, software
18
+ # distributed under the Apache License with the above modification is
19
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
+ # KIND, either express or implied. See the Apache License for the specific
21
+ # language governing permissions and limitations under the Apache License.
22
+ #
23
+
24
+
25
+ module Jamf
26
+
27
+ # This module is the namespace for all objects defined
28
+ # in the OAPI JSON schema under the components => schemas key
29
+ #
30
+ module OAPISchemas
31
+
32
+
33
+ # OAPI Object Model and Enums for: PrestagePurchasingInformationV2
34
+ #
35
+ #
36
+ #
37
+ # This class was automatically generated from the api/schema
38
+ # URL path on a Jamf Pro server version 11.6.1-t1718634702
39
+ #
40
+ # This class may be used directly, e.g instances of other classes may
41
+ # use instances of this class as one of their own properties/attributes.
42
+ #
43
+ # It may also be used as a superclass when implementing Jamf Pro API
44
+ # Resources in ruby-jss. The subclasses include appropriate mixins, and
45
+ # should expand on the basic functionality provided here.
46
+ #
47
+ #
48
+ # Container Objects:
49
+ # Other object models that use this model as the value in one
50
+ # of their attributes.
51
+ # - Jamf::OAPISchemas::DeviceEnrollmentPrestageV2
52
+ #
53
+ # Sub Objects:
54
+ # Other object models used by this model's attributes.
55
+ #
56
+ #
57
+ # Endpoints and Privileges:
58
+ # API endpoints and HTTP operations that use this object
59
+ # model, and the Jamf Pro privileges needed to access them.
60
+ #
61
+ #
62
+ #
63
+ class PrestagePurchasingInformationV2 < Jamf::OAPIObject
64
+
65
+
66
+
67
+ OAPI_PROPERTIES = {
68
+
69
+ # @!attribute id
70
+ # @return [String]
71
+ id: {
72
+ class: :j_id,
73
+ required: true,
74
+ identifier: :primary
75
+ },
76
+
77
+ # @!attribute leased
78
+ # @return [Boolean]
79
+ leased: {
80
+ class: :boolean,
81
+ required: true
82
+ },
83
+
84
+ # @!attribute purchased
85
+ # @return [Boolean]
86
+ purchased: {
87
+ class: :boolean,
88
+ required: true
89
+ },
90
+
91
+ # @!attribute appleCareId
92
+ # @return [String]
93
+ appleCareId: {
94
+ class: :string,
95
+ required: true
96
+ },
97
+
98
+ # @!attribute poNumber
99
+ # @return [String]
100
+ poNumber: {
101
+ class: :string,
102
+ required: true
103
+ },
104
+
105
+ # @!attribute vendor
106
+ # @return [String]
107
+ vendor: {
108
+ class: :string,
109
+ required: true
110
+ },
111
+
112
+ # @!attribute purchasePrice
113
+ # @return [String]
114
+ purchasePrice: {
115
+ class: :string,
116
+ required: true
117
+ },
118
+
119
+ # @!attribute lifeExpectancy
120
+ # @return [Integer]
121
+ lifeExpectancy: {
122
+ class: :integer,
123
+ required: true
124
+ },
125
+
126
+ # @!attribute purchasingAccount
127
+ # @return [String]
128
+ purchasingAccount: {
129
+ class: :string,
130
+ required: true
131
+ },
132
+
133
+ # @!attribute purchasingContact
134
+ # @return [String]
135
+ purchasingContact: {
136
+ class: :string,
137
+ required: true
138
+ },
139
+
140
+ # @!attribute leaseDate
141
+ # @return [String]
142
+ leaseDate: {
143
+ class: :string,
144
+ required: true
145
+ },
146
+
147
+ # @!attribute poDate
148
+ # @return [String]
149
+ poDate: {
150
+ class: :string,
151
+ required: true
152
+ },
153
+
154
+ # @!attribute warrantyDate
155
+ # @return [String]
156
+ warrantyDate: {
157
+ class: :string,
158
+ required: true
159
+ },
160
+
161
+ # @!attribute versionLock
162
+ # @return [Integer]
163
+ versionLock: {
164
+ class: :integer,
165
+ required: true
166
+ }
167
+
168
+ } # end OAPI_PROPERTIES
169
+
170
+ end # class PrestagePurchasingInformationV2
171
+
172
+ end # module OAPISchemas
173
+
174
+ end # module Jamf
@@ -0,0 +1,94 @@
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
+ # with the following modification; you may not use this file except in
5
+ # compliance with the Apache License and the following modification to it:
6
+ # Section 6. Trademarks. is deleted and replaced with:
7
+ #
8
+ # 6. Trademarks. This License does not grant permission to use the trade
9
+ # names, trademarks, service marks, or product names of the Licensor
10
+ # and its affiliates, except as required to comply with Section 4(c) of
11
+ # the License and to reproduce the content of the NOTICE file.
12
+ #
13
+ # You may obtain a copy of the Apache License at
14
+ #
15
+ # http://www.apache.org/licenses/LICENSE-2.0
16
+ #
17
+ # Unless required by applicable law or agreed to in writing, software
18
+ # distributed under the Apache License with the above modification is
19
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
+ # KIND, either express or implied. See the Apache License for the specific
21
+ # language governing permissions and limitations under the Apache License.
22
+ #
23
+
24
+
25
+ module Jamf
26
+
27
+ # This module is the namespace for all objects defined
28
+ # in the OAPI JSON schema under the components => schemas key
29
+ #
30
+ module OAPISchemas
31
+
32
+
33
+ # OAPI Object Model and Enums for: PrestageScopeAssignmentV2
34
+ #
35
+ #
36
+ #
37
+ # This class was automatically generated from the api/schema
38
+ # URL path on a Jamf Pro server version 11.6.1-t1718634702
39
+ #
40
+ # This class may be used directly, e.g instances of other classes may
41
+ # use instances of this class as one of their own properties/attributes.
42
+ #
43
+ # It may also be used as a superclass when implementing Jamf Pro API
44
+ # Resources in ruby-jss. The subclasses include appropriate mixins, and
45
+ # should expand on the basic functionality provided here.
46
+ #
47
+ #
48
+ # Container Objects:
49
+ # Other object models that use this model as the value in one
50
+ # of their attributes.
51
+ # - Jamf::OAPISchemas::PrestageScopeResponseV2
52
+ #
53
+ # Sub Objects:
54
+ # Other object models used by this model's attributes.
55
+ #
56
+ #
57
+ # Endpoints and Privileges:
58
+ # API endpoints and HTTP operations that use this object
59
+ # model, and the Jamf Pro privileges needed to access them.
60
+ #
61
+ #
62
+ #
63
+ class PrestageScopeAssignmentV2 < Jamf::OAPIObject
64
+
65
+
66
+
67
+ OAPI_PROPERTIES = {
68
+
69
+ # @!attribute serialNumber
70
+ # @return [String]
71
+ serialNumber: {
72
+ class: :string
73
+ },
74
+
75
+ # @!attribute assignmentDate
76
+ # @return [Jamf::Timestamp]
77
+ assignmentDate: {
78
+ class: Jamf::Timestamp,
79
+ format: 'date-time'
80
+ },
81
+
82
+ # @!attribute userAssigned
83
+ # @return [String]
84
+ userAssigned: {
85
+ class: :string
86
+ }
87
+
88
+ } # end OAPI_PROPERTIES
89
+
90
+ end # class PrestageScopeAssignmentV2
91
+
92
+ end # module OAPISchemas
93
+
94
+ end # module Jamf
@@ -0,0 +1,91 @@
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
+ # with the following modification; you may not use this file except in
5
+ # compliance with the Apache License and the following modification to it:
6
+ # Section 6. Trademarks. is deleted and replaced with:
7
+ #
8
+ # 6. Trademarks. This License does not grant permission to use the trade
9
+ # names, trademarks, service marks, or product names of the Licensor
10
+ # and its affiliates, except as required to comply with Section 4(c) of
11
+ # the License and to reproduce the content of the NOTICE file.
12
+ #
13
+ # You may obtain a copy of the Apache License at
14
+ #
15
+ # http://www.apache.org/licenses/LICENSE-2.0
16
+ #
17
+ # Unless required by applicable law or agreed to in writing, software
18
+ # distributed under the Apache License with the above modification is
19
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
+ # KIND, either express or implied. See the Apache License for the specific
21
+ # language governing permissions and limitations under the Apache License.
22
+ #
23
+
24
+
25
+ module Jamf
26
+
27
+ # This module is the namespace for all objects defined
28
+ # in the OAPI JSON schema under the components => schemas key
29
+ #
30
+ module OAPISchemas
31
+
32
+
33
+ # OAPI Object Model and Enums for: V1Site
34
+ #
35
+ #
36
+ #
37
+ # This class was automatically generated from the api/schema
38
+ # URL path on a Jamf Pro server version 11.6.1-t1718634702
39
+ #
40
+ # This class may be used directly, e.g instances of other classes may
41
+ # use instances of this class as one of their own properties/attributes.
42
+ #
43
+ # It may also be used as a superclass when implementing Jamf Pro API
44
+ # Resources in ruby-jss. The subclasses include appropriate mixins, and
45
+ # should expand on the basic functionality provided here.
46
+ #
47
+ #
48
+ # Container Objects:
49
+ # Other object models that use this model as the value in one
50
+ # of their attributes.
51
+ # - Jamf::OAPISchemas::AuthorizationV1
52
+ # - Jamf::OAPISchemas::ComputerGeneral
53
+ # - Jamf::OAPISchemas::MobileDeviceDetailsV2
54
+ #
55
+ # Sub Objects:
56
+ # Other object models used by this model's attributes.
57
+ #
58
+ #
59
+ # Endpoints and Privileges:
60
+ # API endpoints and HTTP operations that use this object
61
+ # model, and the Jamf Pro privileges needed to access them.
62
+ # - '/v1/sites:GET' needs permissions:
63
+ # - Read Sites
64
+ #
65
+ #
66
+ class V1Site < Jamf::OAPIObject
67
+
68
+
69
+
70
+ OAPI_PROPERTIES = {
71
+
72
+ # @!attribute id
73
+ # @return [String]
74
+ id: {
75
+ class: :j_id,
76
+ identifier: :primary
77
+ },
78
+
79
+ # @!attribute name
80
+ # @return [String]
81
+ name: {
82
+ class: :string
83
+ }
84
+
85
+ } # end OAPI_PROPERTIES
86
+
87
+ end # class V1Site
88
+
89
+ end # module OAPISchemas
90
+
91
+ end # module Jamf
@@ -25,8 +25,31 @@
25
25
  # The module
26
26
  module Jamf
27
27
 
28
- # This module is the namespace for all objects defined
28
+ # This module is the namespace for all JP API objects defined
29
29
  # in the OAPI JSON schema under the components => schemas key
30
+ #
31
+ # The classes in this module are the Ruby representations of the
32
+ # JSON schema objects (Hashes) in the Jamf Pro OAPI schema
33
+ #
34
+ # Each class is created from the JSON Object definition and other
35
+ # schema data, such as required attributes, the class or type of each
36
+ # attribute (which could be another OAPI object), and any enumurated
37
+ # values for attributes.
38
+ # The classes are all subclasses of Jamf::OAPIObject, which defines
39
+ # common methods for all OAPI objects, such as converting to and from
40
+ # JSON, and validating attribute values.
41
+ #
42
+ # These clases are used in various ways in ruby-jss:
43
+ # - As the value of an attribute in another OAPI object
44
+ # - As the parent class for a Jamf Pro API Resource class
45
+ # - As a representation of a JSON objects sent to or received from the API
46
+ # (e.g. in a POST or PUT request)
47
+ #
48
+ # They are mostly generated automatically using the 'generate_object_models'
49
+ # executable in the 'bin' directory of ruby-jss. After generation the files needed
50
+ # are manually edited to add any needed functionality or clarifications of names
51
+ # etc, and then they are moved into the 'jamf/api/jamf_pro/oapi_schemas' directory.
52
+ #
30
53
  #####################################
31
54
  module OAPISchemas
32
55
 
data/lib/jamf/composer.rb CHANGED
@@ -1,97 +1,104 @@
1
- ### Copyright 2025 Pixar
2
-
3
- ###
4
- ### Licensed under the Apache License, Version 2.0 (the "Apache License")
5
- ### with the following modification; you may not use this file except in
6
- ### compliance with the Apache License and the following modification to it:
7
- ### Section 6. Trademarks. is deleted and replaced with:
8
- ###
9
- ### 6. Trademarks. This License does not grant permission to use the trade
10
- ### names, trademarks, service marks, or product names of the Licensor
11
- ### and its affiliates, except as required to comply with Section 4(c) of
12
- ### the License and to reproduce the content of the NOTICE file.
13
- ###
14
- ### You may obtain a copy of the Apache License at
15
- ###
16
- ### http://www.apache.org/licenses/LICENSE-2.0
17
- ###
18
- ### Unless required by applicable law or agreed to in writing, software
19
- ### distributed under the Apache License with the above modification is
20
- ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
- ### KIND, either express or implied. See the Apache License for the specific
22
- ### language governing permissions and limitations under the Apache License.
23
- ###
24
- ###
25
-
26
- ###
1
+ # Copyright 2025 Pixar
2
+
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "Apache License")
5
+ # with the following modification; you may not use this file except in
6
+ # compliance with the Apache License and the following modification to it:
7
+ # Section 6. Trademarks. is deleted and replaced with:
8
+ #
9
+ # 6. Trademarks. This License does not grant permission to use the trade
10
+ # names, trademarks, service marks, or product names of the Licensor
11
+ # and its affiliates, except as required to comply with Section 4(c) of
12
+ # the License and to reproduce the content of the NOTICE file.
13
+ #
14
+ # You may obtain a copy of the Apache License at
15
+ #
16
+ # http://www.apache.org/licenses/LICENSE-2.0
17
+ #
18
+ # Unless required by applicable law or agreed to in writing, software
19
+ # distributed under the Apache License with the above modification is
20
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
+ # KIND, either express or implied. See the Apache License for the specific
22
+ # language governing permissions and limitations under the Apache License.
23
+ #
24
+ #
25
+
27
26
  module Jamf
28
27
 
29
- ###
30
- ### This module provides two methods for building very simple Casper-happy .pkg and .dmg packages for deployment.
31
- ###
32
- ### Unlike Composer.app from JAMF, this module currently doesn't offer a way to do a before/after disk scan
33
- ### and use the differences to build the root folder from which the package is built. Nor does the module support
34
- ### editing the pre/post install scripts in .pkgs.
35
- ###
36
- ### The 'root folder', a folder representing the root filesystem of the target machine where the package will be installed,
37
- ### must already exist and be fully populated and with correct permissions.
38
- ###
28
+ # This module provides two methods for building very simple Casper-happy .pkg and .dmg
29
+ # packages for deployment.
30
+ #
31
+ # Unlike Composer.app from JAMF, this module currently doesn't offer a way to do a
32
+ # before/after disk scan
33
+ # and use the differences to build the root folder from which the package is built.
34
+ # Nor does the module support
35
+ # editing the pre/post install scripts in .pkgs.
36
+ #
37
+ # The 'root folder', a folder representing the root filesystem of the target machine
38
+ # where the package will be installed,
39
+ # must already exist and be fully populated and with correct permissions.
40
+ #
41
+ #
42
+ # TODO: Support building Distribution-style packages using the 'productbuild' tool,
43
+ # since they are needed for deploying packages via MDM - Component packages created
44
+ # by pkgbuild are not supported for MDM deployment.
45
+ #
39
46
  module Composer
40
47
 
41
48
  #####################################
42
- ### Constants
49
+ # Constants
43
50
  #####################################
44
51
 
45
- ### the apple pkgutil tool
52
+ # the apple pkgutil tool
46
53
  PKG_UTIL = Pathname.new '/usr/sbin/pkgutil'
47
54
 
48
- ### The location of the cli tool for making .pkgs
55
+ # The location of the cli tool for making .pkgs
49
56
  PKGBUILD = Pathname.new '/usr/bin/pkgbuild'
50
57
 
51
- ### the default bundle identifier prefix for pkgs
58
+ # the default bundle identifier prefix for pkgs
52
59
  PKG_BUNDLE_ID_PFX = 'ruby-jss-composer'.freeze
53
60
 
54
- ### Apple's hdiutil for making dmgs
61
+ # Apple's hdiutil for making dmgs
55
62
  HDI_UTIL = '/usr/bin/hdiutil'.freeze
56
63
 
57
- ### Where to save the output ?
64
+ # Where to save the output ?
58
65
  DEFAULT_OUT_DIR = Pathname.new '/Users/Shared'
59
66
 
60
- ### Make a casper-happy .pkg out of a root folder, permissions are assumed to be correct.
61
- ###
62
- ### @param name[String] the name of the .pkg. The .pkg suffix will be added if not present
63
- ###
64
- ### @param version[String] the version of the .pkg, needed for building the .pkg
65
- ###
66
- ### @param root[String, Pathname] the path to the 'root folder' representing
67
- ### the root file system of the target install drive
68
- ###
69
- ### @param opts[Hash] the options for building the .pkg
70
- ###
71
- ### @options opts :pkg_id[String] the full package if for the new pkg.
72
- ### e.g. 'com.mycompany.myapp'
73
- ###
74
- ### @option opts :bundle_id_prefix[String] the pkg bundle identifier prefix.
75
- ### If no :pkg_id is provided, one is made using this prefix and
76
- ### the name provided. e.g. 'com.mycompany'
77
- ### Defaults to '{PKG_BUNDLE_ID_PFX}'. See 'man pkgbuild' for more info
78
- ###
79
- ### @option opts :out_dir[String,Pathname] he folder in which the .pkg will be
80
- ### created. Defaults to {DEFAULT_OUT_DIR}
81
- ###
82
- ### @option opts :preserve_ownership[Boolean] If true, the owner/group of the
83
- ### rootpath are preserved.
84
- ### Default is false: they become the pkgbuild/installer 'recommended'
85
- ### (root/wheel or root/admin)
86
- ###
87
- ### @option opts :signing_identity[String] the optional name of the signing identity (certificate) to
88
- ### use for signing the pkg. See `man pkgbuild` for details
89
- ###
90
- ### @option opts :signing_options[String] the optional string of options to pass to pkgbuild.
91
- ### See `man pkgbuild` for details
92
- ###
93
- ### @return [Pathname] the local path to the new .pkg
94
- ###
67
+ # Make a casper-happy .pkg out of a root folder, permissions are assumed to be correct.
68
+ #
69
+ # @param name[String] the name of the .pkg. The .pkg suffix will be added if not present
70
+ #
71
+ # @param version[String] the version of the .pkg, needed for building the .pkg
72
+ #
73
+ # @param root[String, Pathname] the path to the 'root folder' representing
74
+ # the root file system of the target install drive
75
+ #
76
+ # @param opts[Hash] the options for building the .pkg
77
+ #
78
+ # @options opts :pkg_id[String] the full package if for the new pkg.
79
+ # e.g. 'com.mycompany.myapp'
80
+ #
81
+ # @option opts :bundle_id_prefix[String] the pkg bundle identifier prefix.
82
+ # If no :pkg_id is provided, one is made using this prefix and
83
+ # the name provided. e.g. 'com.mycompany'
84
+ # Defaults to '{PKG_BUNDLE_ID_PFX}'. See 'man pkgbuild' for more info
85
+ #
86
+ # @option opts :out_dir[String,Pathname] he folder in which the .pkg will be
87
+ # created. Defaults to {DEFAULT_OUT_DIR}
88
+ #
89
+ # @option opts :preserve_ownership[Boolean] If true, the owner/group of the
90
+ # rootpath are preserved.
91
+ # Default is false: they become the pkgbuild/installer 'recommended'
92
+ # (root/wheel or root/admin)
93
+ #
94
+ # @option opts :signing_identity[String] the optional name of the signing identity (certificate) to
95
+ # use for signing the pkg. See `man pkgbuild` for details
96
+ #
97
+ # @option opts :signing_options[String] the optional string of options to pass to pkgbuild.
98
+ # See `man pkgbuild` for details
99
+ #
100
+ # @return [Pathname] the local path to the new .pkg
101
+ #
95
102
  def self.mk_pkg(name, version, root, **opts)
96
103
  raise NoSuchItemError, "Missing pkgbuild tool. Please make sure you're running 10.8 or later." unless PKGBUILD.executable?
97
104
 
@@ -111,28 +118,28 @@ module Jamf
111
118
  signing = ''
112
119
  end # if opts[:signing_identity]
113
120
 
114
- ### first, run 'analyze' to get a 'component plist' in which we can change some settings
115
- ### for any bundles in the root (bundles like .apps, frameworks, plugins, etc..)
116
- ###
117
- ### we edit the settings thus:
118
- ### BundleOverwriteAction = upgrade, totally replace any version current on disk
119
- ### BundleIsVersionChecked = false, allow us to install regardless of what version is currently installed
120
- ### BundleIsRelocatable = false, if there's a version of this in some other location, Do Not move this one there after installation
121
- ### BundleHasStrictIdentifier = false, don't care if there's something at the install path with a different bundle id.
122
- ###
123
- ### In other words, just install the thing!
124
- ### (see 'man pkgbuild' for more info)
125
- ###
126
- ###
121
+ # first, run 'analyze' to get a 'component plist' in which we can change some settings
122
+ # for any bundles in the root (bundles like .apps, frameworks, plugins, etc..)
123
+ #
124
+ # we edit the settings thus:
125
+ # BundleOverwriteAction = upgrade, totally replace any version current on disk
126
+ # BundleIsVersionChecked = false, allow us to install regardless of what version is currently installed
127
+ # BundleIsRelocatable = false, if there's a version of this in some other location, Do Not move this one there after installation
128
+ # BundleHasStrictIdentifier = false, don't care if there's something at the install path with a different bundle id.
129
+ #
130
+ # In other words, just install the thing!
131
+ # (see 'man pkgbuild' for more info)
132
+ #
133
+ #
127
134
  comp_plist_out = Pathname.new "/tmp/#{PKG_BUNDLE_ID_PFX}-#{pkg_filename}.plist"
128
135
  system "#{PKGBUILD} --analyze --root '#{root}' '#{comp_plist_out}'"
129
136
  comp_plist = JSS.parse_plist comp_plist_out
130
137
 
131
- ### if the plist is empty, there are no bundles in the pkg
138
+ # if the plist is empty, there are no bundles in the pkg
132
139
  if comp_plist[0].nil?
133
140
  comp_plist_arg = ''
134
141
  else
135
- ### otherwise, edit the bundle dictionaries
142
+ # otherwise, edit the bundle dictionaries
136
143
  comp_plist.each do |bndl|
137
144
  bndl.delete 'ChildBundles' if bndl['ChildBundles']
138
145
  bndl['BundleOverwriteAction'] = 'upgrade'
@@ -140,12 +147,12 @@ module Jamf
140
147
  bndl['BundleIsRelocatable'] = false
141
148
  bndl['BundleHasStrictIdentifier'] = false
142
149
  end
143
- ### write out the edits
150
+ # write out the edits
144
151
  comp_plist_out.open('w') { |f| f.write JSS.xml_plist_from(comp_plist) }
145
152
  comp_plist_arg = "--component-plist '#{comp_plist_out}'"
146
153
  end
147
154
 
148
- ### now build the pkg
155
+ # now build the pkg
149
156
  begin
150
157
  it_built = system "#{PKGBUILD} --identifier '#{pkg_id}' --version '#{version}' --ownership #{pkg_ownership} --install-location / --root '#{root}' #{signing} #{comp_plist_arg} '#{pkg_out}'"
151
158
 
@@ -157,18 +164,18 @@ module Jamf
157
164
  Pathname.new pkg_out
158
165
  end # mk_dot_pkg
159
166
 
160
- ###
161
- ### Make a casper-happy .dmg out of a root folder, permissions are assumed to be correct.
162
- ###
163
- ### @param name[String] The name of the .dmg, the suffix will be added if needed
164
- ###
165
- ### @param root[String, Pathname] the path to the "root folder" representing the root file system of the target install drive
166
- ###
167
- ### @param out_dir[String, Pathname] the folder in which the .pkg will be created. Defaults to {DEFAULT_OUT_DIR}
168
- ###
169
- ### @return [Pathname] the local path to the new .dmg
170
- ###
171
- ###
167
+ #
168
+ # Make a casper-happy .dmg out of a root folder, permissions are assumed to be correct.
169
+ #
170
+ # @param name[String] The name of the .dmg, the suffix will be added if needed
171
+ #
172
+ # @param root[String, Pathname] the path to the "root folder" representing the root file system of the target install drive
173
+ #
174
+ # @param out_dir[String, Pathname] the folder in which the .pkg will be created. Defaults to {DEFAULT_OUT_DIR}
175
+ #
176
+ # @return [Pathname] the local path to the new .dmg
177
+ #
178
+ #
172
179
  def self.mk_dmg(name, root, out_dir = DEFAULT_OUT_DIR)
173
180
  dmg_filename = "#{name}.dmg"
174
181
  dmg_vol = name
@@ -178,7 +185,7 @@ module Jamf
178
185
  dmg_out.rename mv_to
179
186
  end # if dmg out exist
180
187
 
181
- ### TODO - this may need to be sudo'd to handle proper internal permissions.
188
+ # TODO: - this may need to be sudo'd to handle proper internal permissions.
182
189
  system "#{HDI_UTIL} create -volname '#{dmg_vol}' -scrub -srcfolder '#{root}' '#{dmg_out}'"
183
190
 
184
191
  raise 'There was an error building the .dmg' unless $?.exitstatus.zero?
@@ -163,6 +163,7 @@ module Jamf
163
163
 
164
164
  # try to instantiate the class with the value. It should raise an error
165
165
  # if not good
166
+ # TODO: Does this method name need to be in Jamf::JPAPIResource::NEW_CALLERS
166
167
  klass.new val
167
168
  rescue => e
168
169
  raise_invalid_data_error(msg || "#{attr_name} value must be a #{klass}, or #{klass}.new must accept it as the only parameter, but #{klass}.new raised: #{e.class}: #{e}")