@@ -152,8 +152,8 @@ def __init__(self):
152
152
"DirectoryBindings" : post_template2 ,
153
153
"Ebooks" : post_template2 ,
154
154
"JSONWebTokenConfigurations" : post_template2 ,
155
- # ' LicensedSoftware' : post_template2,
156
- # ' LDAPServers' : post_template2,
155
+ #" LicensedSoftware" : post_template2,
156
+ #" LDAPServers" : post_template2,
157
157
"MacApplications" : post_template2 ,
158
158
"ManagedPreferenceProfiles" : post_template2 ,
159
159
"MobileDevices" : post_template2 ,
@@ -162,7 +162,6 @@ def __init__(self):
162
162
"MobileDeviceEnrollmentProfiles" : post_template2 ,
163
163
"MobileDeviceProvisioningProfiles" : post_template2 ,
164
164
"OSXConfigurationProfiles" : post_template2 ,
165
- "PatchPolicies" : post_template2 ,
166
165
"Peripherals" : post_template2 ,
167
166
"Policies" : post_template2 ,
168
167
"SoftwareUpdateServers" : post_template2 ,
@@ -199,8 +198,11 @@ def __init__(self):
199
198
"name" : "%NAME%" ,
200
199
"host_name" : "example.com" ,
201
200
},
202
- "PatchSoftwareTitles" : {"name" : "%NAME%" , "source_id" : "1" },
203
- # 'RestrictedSoftware': {'general':{'name':'%NAME%','process_name':'%NAME%'}},
201
+ "PatchPolicies" : {
202
+ "general" : {"name" : "%NAME%" , "target_version" : "%VERSION%" }
203
+ },
204
+ "PatchSoftwareTitles" : {"name_id" : "%NAME%" , "source_id" : "1" },
205
+ #"RestrictedSoftware": {"general":{"name":"%NAME%","process_name":"%NAME%"}},
204
206
"UserGroups" : {"general" : {"name" : "%NAME%" }, "is_smart" : False },
205
207
"WebHooks" : {
206
208
"event" : "ComputerAdded" ,
@@ -359,7 +361,10 @@ def __new__(cls, *a, **kw):
359
361
returns existing record if one has been instantiated
360
362
"""
361
363
jamf_id = int (a [0 ])
362
- name = a [1 ]
364
+ if type (a [1 ]) is str :
365
+ name = a [1 ]
366
+ else :
367
+ name = a [1 ][0 ]
363
368
if not hasattr (cls , "_instances" ):
364
369
cls ._instances = {}
365
370
swag = ClassicSwagger ()
@@ -376,11 +381,15 @@ def __new__(cls, *a, **kw):
376
381
return None
377
382
s1 , s2 , end = swag .swagger (plural , "s1, s2, end" )
378
383
if cls .plural_class == "PatchPolicies" :
379
- print (
380
- "Use /patchpolicies/softwaretitleconfig/id/{softwaretitleconfigid}"
381
- " instead"
384
+ if len (a [1 ]) < 3 :
385
+ raise Error (f"patchpolicies requires 3 args to create records" )
386
+ softwaretitleconfigid = a [1 ][1 ]
387
+ end = f"patchpolicies/softwaretitleconfig/id/{ softwaretitleconfigid } "
388
+ out = {s1 : swag .post_template (cls .plural_class , name )}
389
+ t = out ["patch_policy" ]["general" ]["target_version" ]
390
+ out ["patch_policy" ]["general" ]["target_version" ] = t .replace (
391
+ "%VERSION%" , a [1 ][2 ]
382
392
)
383
- return None
384
393
else :
385
394
end = f"{ end } 0"
386
395
out = {s1 : swag .post_template (cls .plural_class , name )}
@@ -1158,15 +1167,6 @@ class PatchPolicy(Record):
1158
1167
def set_version_update_during (self , pkg_version ):
1159
1168
change_made = False
1160
1169
cur_ver = self .data ["general" ]["target_version" ]
1161
-
1162
- #######################################################################
1163
- # If you don't delete the self_service_icon then it will error
1164
- # <Response [409]>: PUT - https://example.com:8443/JSSResource/patchpolicies/id/18:
1165
- # Conflict: Error: Problem with icon
1166
- # Couldn't save changed record: <Response [409]>
1167
- del self .data ["user_interaction" ]["self_service_icon" ]
1168
- #######################################################################
1169
-
1170
1170
if cur_ver != pkg_version :
1171
1171
print (f"Set version to { pkg_version } " )
1172
1172
self .data ["general" ]["target_version" ] = pkg_version
@@ -1175,6 +1175,15 @@ def set_version_update_during(self, pkg_version):
1175
1175
print (f"Version is already { pkg_version } " )
1176
1176
return change_made
1177
1177
1178
+ def save (self ):
1179
+ # If you don't delete the self_service_icon then it will error
1180
+ # <Response [409]>: PUT - https://example.com:8443/JSSResource/patchpolicies/id/18:
1181
+ # Conflict: Error: Problem with icon
1182
+ # Couldn't save changed record: <Response [409]>
1183
+ if "self_service_icon" in self .data ["user_interaction" ]:
1184
+ del self .data ["user_interaction" ]["self_service_icon" ]
1185
+ return super ().save ()
1186
+
1178
1187
1179
1188
class PatchPolicies (Records , metaclass = Singleton ):
1180
1189
singular_class = PatchPolicy
@@ -1263,6 +1272,17 @@ def set_package_for_version_update_during(self, package, target_version):
1263
1272
change_made = True
1264
1273
return change_made
1265
1274
1275
+ def versions_print_during (self ):
1276
+ print (self .name )
1277
+ versions = self .data ["versions" ]["version" ]
1278
+ if not type (versions ) is list :
1279
+ versions = [versions ]
1280
+ for version in versions :
1281
+ if version ["package" ] != None :
1282
+ print (f" { version ['software_version' ]} : { version ['package' ]['name' ]} " )
1283
+ else :
1284
+ print (f" { version ['software_version' ]} : -" )
1285
+
1266
1286
1267
1287
class PatchSoftwareTitles (Records , metaclass = Singleton ):
1268
1288
singular_class = PatchSoftwareTitle
@@ -1271,6 +1291,7 @@ class PatchSoftwareTitles(Records, metaclass=Singleton):
1271
1291
"packages" : {"required_args" : 0 , "args_description" : "" },
1272
1292
"set_package_for_version" : {"required_args" : 2 , "args_description" : "" },
1273
1293
"set_all_packages" : {"required_args" : 0 , "args_description" : "" },
1294
+ "versions" : {"required_args" : 0 , "args_description" : "" },
1274
1295
}
1275
1296
1276
1297
0 commit comments