mdata 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: faff685b0e5287c5c54d944f31011ca28d113241
4
- data.tar.gz: 12e1cfd3508ba85da9372d305202c1af962c7a7c
3
+ metadata.gz: d5c5c90e7844acf88c75a815848b11be55720b2b
4
+ data.tar.gz: e0fc9d5520935aa2665d4a48e5c5205667635a53
5
5
  SHA512:
6
- metadata.gz: 0ef8902458d53e2c807f321417cf88d0cfe167602c248fe22efc26e534015688b36805f9f85204109cb5377eb1dbec58d5292d5d151e6387db0e03fc125a2446
7
- data.tar.gz: 4b63b2a5e5dc49d42946ae6d2a1cc2cce2cdf22929d977c51fb762d952c64b13845c1d9a4ecae4c9f6a0b07c1bbbce362f8f0a82ce165b0a9fd4cce782264699
6
+ metadata.gz: d12e73f44b6bcb30fe20afc67b3b6a5f81c2a6adb936b20d59679cbd16e97329e1496e0524d612f12d59c3b94f1a3cf2ed1a2400b0df4e4b16eb5c808fbc14a1
7
+ data.tar.gz: b7d9b3633dffb09baf1971ad99f6581af09a2e6846f8798f68ebdaf4594ca4b9240c6a1345d59147d0857156040f2ce2df652c1469d607648d5f9758711992e9
data/bin/mdata CHANGED
@@ -5,7 +5,7 @@ require 'commander/import'
5
5
  require 'mdata/metadata'
6
6
  require 'terminal-table'
7
7
 
8
- program :version, '1.2.0'
8
+ program :version, '1.3.0'
9
9
  program :description, 'Your Salesforce metadata navigator and manipulator'
10
10
  program :help, 'Author', 'Ben Burwell <ben.burwell@trifecta.com>'
11
11
 
@@ -25,15 +25,29 @@ command 'profile create' do |c|
25
25
  end
26
26
  end
27
27
 
28
+ command 'permissionset create' do |c|
29
+ c.syntax = 'mdata permissionset create --permissionset PERMISSIONSET'
30
+ c.summary = 'Create a new permission set'
31
+ c.option '--permissionset PERMISSIONSET', String, 'The name of the permissionset to create'
32
+ c.action do |args, opts|
33
+ begin
34
+ raise ArgumentError, 'no permission set specified' if opts.permissionset.nil?
35
+ Salesforce::Metadata::PermissionSet.touch opts.permissionset, opts.dir
36
+ rescue ArgumentError => e
37
+ puts "Error executing command: #{e.message}"
38
+ end
39
+ end
40
+ end
41
+
28
42
  # Profile - Field Permissions - Read
29
43
  command :'profile fieldPermissions:read' do |c|
30
- c.syntax = 'mdata profile fieldPermission:read --profile PROFILE [options]'
31
- c.summary = 'See what permissions a particular profile is granted'
32
- c.option '--profile PROFILE', String, 'The profile to examine'
33
- c.option '--field FIELD', String, 'Optionally, a specific field to look for.'
34
- c.action do |args, opts|
35
- begin
36
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
44
+ c.syntax = 'mdata profile fieldPermission:read --profile PROFILE [options]'
45
+ c.summary = 'See what permissions a particular profile is granted'
46
+ c.option '--profile PROFILE', String, 'The profile to examine'
47
+ c.option '--field FIELD', String, 'Optionally, a specific field to look for.'
48
+ c.action do |args, opts|
49
+ begin
50
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
37
51
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
38
52
  profile.fieldPermissions.keep_if { |x| x.field == opts.field } unless opts.field.nil?
39
53
  profile.fieldPermissions.sort! { |a, b| a.field <=> b.field }
@@ -45,24 +59,24 @@ command :'profile fieldPermissions:read' do |c|
45
59
  end
46
60
  table = Terminal::Table.new :rows => rows, :headings => ['Object', 'Field', 'Permissions']
47
61
  puts table
48
- rescue ArgumentError => e
49
- puts "Error executing command: #{e.message}"
50
- end
51
- end
62
+ rescue ArgumentError => e
63
+ puts "Error executing command: #{e.message}"
64
+ end
65
+ end
52
66
  end
53
67
 
54
68
  # Profile - Field Permissions - Set
55
69
  command :'profile fieldPermissions:set' do |c|
56
- c.syntax = 'mdata profile fieldPermissions:set --profile PROFILE --field FIELD [options]'
57
- c.summary = 'Overwrites any existing permissions for the field on the profile with the ones specified'
58
- c.option '--profile PROFILE', String, 'The profile to configure'
59
- c.option '--field FIELD', String, 'The field to assign permissions for'
60
- c.option '--readable', 'Set the read permission'
61
- c.option '--editable', 'Set the edit permission'
62
- c.option '--hidden', 'Set the field to be hidden'
63
- c.action do |args, opts|
64
- begin
65
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
70
+ c.syntax = 'mdata profile fieldPermissions:set --profile PROFILE --field FIELD [options]'
71
+ c.summary = 'Overwrites any existing permissions for the field on the profile with the ones specified'
72
+ c.option '--profile PROFILE', String, 'The profile to configure'
73
+ c.option '--field FIELD', String, 'The field to assign permissions for'
74
+ c.option '--readable', 'Set the read permission'
75
+ c.option '--editable', 'Set the edit permission'
76
+ c.option '--hidden', 'Set the field to be hidden'
77
+ c.action do |args, opts|
78
+ begin
79
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
66
80
  raise ArgumentError, 'no field specified' if opts.field.nil?
67
81
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
68
82
  idx = profile.fieldPermissions.find_index { |x| x.field == opts.field }
@@ -87,24 +101,24 @@ command :'profile fieldPermissions:set' do |c|
87
101
  else 'true'
88
102
  end
89
103
  profile.save
90
- rescue ArgumentError => e
91
- puts "Error executing command: #{e.message}"
92
- end
93
- end
104
+ rescue ArgumentError => e
105
+ puts "Error executing command: #{e.message}"
106
+ end
107
+ end
94
108
  end
95
109
 
96
110
  # Profile - Field Permissions - Grant
97
111
  command :'profile fieldPermissions:grant' do |c|
98
- c.syntax = 'mdata profile fieldPermissions:grant --profile PROFILE --field FIELD [options]'
99
- c.summary = 'Grants the specified permission on the field to the profile and leaves all others intact'
100
- c.option '--profile PROFILE', String, 'The profile to configure'
101
- c.option '--field FIELD', String, 'The field to grant permissions on'
102
- c.option '--readable', 'Grant the read permission'
103
- c.option '--editable', 'Grant the edit permission'
104
- c.option '--hidden', 'Make the field hidden'
105
- c.action do |args, opts|
106
- begin
107
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
112
+ c.syntax = 'mdata profile fieldPermissions:grant --profile PROFILE --field FIELD [options]'
113
+ c.summary = 'Grants the specified permission on the field to the profile and leaves all others intact'
114
+ c.option '--profile PROFILE', String, 'The profile to configure'
115
+ c.option '--field FIELD', String, 'The field to grant permissions on'
116
+ c.option '--readable', 'Grant the read permission'
117
+ c.option '--editable', 'Grant the edit permission'
118
+ c.option '--hidden', 'Make the field hidden'
119
+ c.action do |args, opts|
120
+ begin
121
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
108
122
  raise ArgumentError, 'no field specified' if opts.field.nil?
109
123
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
110
124
  idx = profile.fieldPermissions.find_index { |x| x.field == opts.field }
@@ -120,24 +134,24 @@ command :'profile fieldPermissions:grant' do |c|
120
134
  profile.fieldPermissions[idx].editable = 'true' unless opts.editable.nil?
121
135
  profile.fieldPermissions[idx].hidden = 'true' unless opts.hidden.nil?
122
136
  profile.save
123
- rescue ArgumentError => e
124
- puts "Error executing command: #{e.message}"
125
- end
126
- end
137
+ rescue ArgumentError => e
138
+ puts "Error executing command: #{e.message}"
139
+ end
140
+ end
127
141
  end
128
142
 
129
143
  # Profile - Field Permissions - Revoke
130
144
  command :'profile fieldPermissions:revoke' do |c|
131
- c.syntax = 'mdata profile fieldPermissions:revoke --profile PROFILE --field FIELD [options]'
132
- c.summary = 'Revokes the specified permission on the field to the profile and leaves all others intact'
133
- c.option '--profile PROFILE', String, 'The profile to configure'
134
- c.option '--field FIELD', String, 'The field to revoke permissions on'
135
- c.option '--readable', 'Revoke the read permission'
136
- c.option '--editable', 'Revoke the edit permission'
137
- c.option '--hidden', 'Remove the hidden flag'
138
- c.action do |args, opts|
139
- begin
140
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
145
+ c.syntax = 'mdata profile fieldPermissions:revoke --profile PROFILE --field FIELD [options]'
146
+ c.summary = 'Revokes the specified permission on the field to the profile and leaves all others intact'
147
+ c.option '--profile PROFILE', String, 'The profile to configure'
148
+ c.option '--field FIELD', String, 'The field to revoke permissions on'
149
+ c.option '--readable', 'Revoke the read permission'
150
+ c.option '--editable', 'Revoke the edit permission'
151
+ c.option '--hidden', 'Remove the hidden flag'
152
+ c.action do |args, opts|
153
+ begin
154
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
141
155
  raise ArgumentError, 'no field specified' if opts.field.nil?
142
156
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
143
157
  idx = profile.fieldPermissions.find_index { |x| x.field == opts.field }
@@ -146,37 +160,37 @@ command :'profile fieldPermissions:revoke' do |c|
146
160
  profile.fieldPermissions[idx].editable = 'false' unless opts.editable.nil?
147
161
  profile.fieldPermissions[idx].hidden = 'false' unless opts.hidden.nil?
148
162
  profile.save
149
- rescue ArgumentError => e
150
- puts "Error executing command: #{e.message}"
151
- end
152
- end
163
+ rescue ArgumentError => e
164
+ puts "Error executing command: #{e.message}"
165
+ end
166
+ end
153
167
  end
154
168
 
155
169
  # Profile - Field Permissions - Copy
156
170
  command :'profile fieldPermissions:copy' do |c|
157
- c.syntax = 'mdata profile fieldPermissions:copy --fromProfile PROFILE --toProfile PROFILE --fromField FIELD --toField FIELD [options]'
158
- c.summary = 'Copies the specified permissions for a field from one profile to another'
159
- c.description = [
160
- 'Copies the permissions on fromProfile for the object fromField to toField on toProfile.',
161
- '',
162
- 'If you are copying the permissions from one field to another on the same profile, you can use',
163
- 'the --profile option rather than specifying the same --fromProfile and --toProfile.',
164
- '',
165
- 'Likewise, if you are copying the permissions for an field from one profile to another, you can',
166
- 'specify an --field rather than a --fromField and --toField.'
167
- ].join("\n")
168
- c.option '--fromProfile PROFILE', String, 'The source profile'
169
- c.option '--toProfile PROFILE', String, 'The destination profile'
170
- c.option '--profile PROFILE', String, 'A profile to use as the source and destination'
171
- c.option '--fromField FIELD', String, 'The source field'
172
- c.option '--toField FIELD', String, 'The destination field'
173
- c.option '--field FIELD', String, 'A field to use as the source and destination'
174
- c.option '--all', 'Copy all permissions'
175
- c.option '--readable', 'Copy the read permission'
176
- c.option '--editable', 'Copy the edit permission'
177
- c.option '--hidden', 'Copy the hidden permission'
178
- c.action do |args, opts|
179
- # Override options for helper options
171
+ c.syntax = 'mdata profile fieldPermissions:copy --fromProfile PROFILE --toProfile PROFILE --fromField FIELD --toField FIELD [options]'
172
+ c.summary = 'Copies the specified permissions for a field from one profile to another'
173
+ c.description = [
174
+ 'Copies the permissions on fromProfile for the object fromField to toField on toProfile.',
175
+ '',
176
+ 'If you are copying the permissions from one field to another on the same profile, you can use',
177
+ 'the --profile option rather than specifying the same --fromProfile and --toProfile.',
178
+ '',
179
+ 'Likewise, if you are copying the permissions for an field from one profile to another, you can',
180
+ 'specify an --field rather than a --fromField and --toField.'
181
+ ].join("\n")
182
+ c.option '--fromProfile PROFILE', String, 'The source profile'
183
+ c.option '--toProfile PROFILE', String, 'The destination profile'
184
+ c.option '--profile PROFILE', String, 'A profile to use as the source and destination'
185
+ c.option '--fromField FIELD', String, 'The source field'
186
+ c.option '--toField FIELD', String, 'The destination field'
187
+ c.option '--field FIELD', String, 'A field to use as the source and destination'
188
+ c.option '--all', 'Copy all permissions'
189
+ c.option '--readable', 'Copy the read permission'
190
+ c.option '--editable', 'Copy the edit permission'
191
+ c.option '--hidden', 'Copy the hidden permission'
192
+ c.action do |args, opts|
193
+ # Override options for helper options
180
194
  opts.fromProfile = opts.profile if opts.profile
181
195
  opts.toProfile = opts.profile if opts.profile
182
196
  opts.fromField = opts.field if opts.field
@@ -184,10 +198,10 @@ command :'profile fieldPermissions:copy' do |c|
184
198
  opts.readable = true if opts.all
185
199
  opts.editable = true if opts.all
186
200
  opts.hidden = true if opts.all
187
-
188
- begin
189
- raise ArgumentError, 'no source profile specified' if opts.fromProfile.nil?
190
- raise ArgumentError, 'no destination profile specified' if opts.toProfile.nil?
201
+
202
+ begin
203
+ raise ArgumentError, 'no source profile specified' if opts.fromProfile.nil?
204
+ raise ArgumentError, 'no destination profile specified' if opts.toProfile.nil?
191
205
  raise ArgumentError, 'no source field specified' if opts.fromField.nil?
192
206
  raise ArgumentError, 'no destination field specified' if opts.toField.nil?
193
207
 
@@ -219,29 +233,29 @@ command :'profile fieldPermissions:copy' do |c|
219
233
  end
220
234
 
221
235
  to_profile.save
222
- rescue ArgumentError => e
223
- puts "Error executing command: #{e.message}"
224
- end
225
- end
236
+ rescue ArgumentError => e
237
+ puts "Error executing command: #{e.message}"
238
+ end
239
+ end
226
240
  end
227
241
 
228
242
  # Profile - Field Permissions - Revoke
229
243
  command :'profile fieldPermissions:delete' do |c|
230
- c.syntax = 'mdata profile fieldPermissions:delete --profile PROFILE --field FIELD'
231
- c.summary = 'Completely removes the permissions for a particular field. Useful if a field is deleted from an object.'
232
- c.option '--profile PROFILE', String, 'The profile to configure'
233
- c.option '--field FIELD', String, 'The field to revoke permissions on'
234
- c.action do |args, opts|
235
- begin
236
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
244
+ c.syntax = 'mdata profile fieldPermissions:delete --profile PROFILE --field FIELD'
245
+ c.summary = 'Completely removes the permissions for a particular field. Useful if a field is deleted from an object.'
246
+ c.option '--profile PROFILE', String, 'The profile to configure'
247
+ c.option '--field FIELD', String, 'The field to revoke permissions on'
248
+ c.action do |args, opts|
249
+ begin
250
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
237
251
  raise ArgumentError, 'no field specified' if opts.field.nil?
238
252
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
239
253
  profile.fieldPermissions.delete_if { |x| x.field == opts.field }
240
254
  profile.save
241
- rescue ArgumentError => e
242
- puts "Error executing command: #{e.message}"
243
- end
244
- end
255
+ rescue ArgumentError => e
256
+ puts "Error executing command: #{e.message}"
257
+ end
258
+ end
245
259
  end
246
260
 
247
261
  # Profile - Class Access - Read
@@ -252,7 +266,7 @@ command :'profile classAccess:read' do |c|
252
266
  c.option '--class CLASS', String, 'Optionally, a particular class to look for'
253
267
  c.action do |args, opts|
254
268
  begin
255
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
269
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
256
270
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
257
271
  profile.classAccesses.keep_if { |x| x.apexClass == opts.class } unless opts.class.nil?
258
272
  profile.classAccesses.sort! { |a, b| a.apexClass <=> b.apexClass }
@@ -262,10 +276,10 @@ command :'profile classAccess:read' do |c|
262
276
  end
263
277
  table = Terminal::Table.new :rows => rows, :headings => ['Class', 'Enabled']
264
278
  puts table
265
- rescue ArgumentError => e
266
- puts "Error executing command: #{e.message}"
267
- end
268
- end
279
+ rescue ArgumentError => e
280
+ puts "Error executing command: #{e.message}"
281
+ end
282
+ end
269
283
  end
270
284
 
271
285
  # Profile - Class Access - Grant
@@ -410,19 +424,19 @@ end
410
424
 
411
425
  # Profile - Object Permissions - Set
412
426
  command :'profile objectPermissions:set' do |c|
413
- c.syntax = 'mdata profile objectPermissions:set --profile PROFILE --object OBJECT [options]'
414
- c.summary = 'Overwrites any existing permissions for the object on the profile with the ones specified'
415
- c.option '--profile PROFILE', String, 'The profile to configure'
416
- c.option '--object OBJECT', String, 'The object to assign permissions for'
417
- c.option '--allowCreate', 'Set the allowCreate permission'
418
- c.option '--allowEdit', 'Set the allowEdit permission'
419
- c.option '--allowRead', 'Set the allowRead permission'
420
- c.option '--allowDelete', 'Set the allowDelete permission'
421
- c.option '--modifyAllRecords', 'Set the modifyAllRecords permission'
422
- c.option '--viewAllRecords', 'Set the viewAllRecords permission'
423
- c.action do |args, opts|
424
- begin
425
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
427
+ c.syntax = 'mdata profile objectPermissions:set --profile PROFILE --object OBJECT [options]'
428
+ c.summary = 'Overwrites any existing permissions for the object on the profile with the ones specified'
429
+ c.option '--profile PROFILE', String, 'The profile to configure'
430
+ c.option '--object OBJECT', String, 'The object to assign permissions for'
431
+ c.option '--allowCreate', 'Set the allowCreate permission'
432
+ c.option '--allowEdit', 'Set the allowEdit permission'
433
+ c.option '--allowRead', 'Set the allowRead permission'
434
+ c.option '--allowDelete', 'Set the allowDelete permission'
435
+ c.option '--modifyAllRecords', 'Set the modifyAllRecords permission'
436
+ c.option '--viewAllRecords', 'Set the viewAllRecords permission'
437
+ c.action do |args, opts|
438
+ begin
439
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
426
440
  raise ArgumentError, 'no object specified' if opts.object.nil?
427
441
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
428
442
  idx = profile.objectPermissions.find_index { |x| x.object == opts.object }
@@ -459,27 +473,27 @@ command :'profile objectPermissions:set' do |c|
459
473
  else 'true'
460
474
  end
461
475
  profile.save
462
- rescue ArgumentError => e
463
- puts "Error executing command: #{e.message}"
464
- end
465
- end
476
+ rescue ArgumentError => e
477
+ puts "Error executing command: #{e.message}"
478
+ end
479
+ end
466
480
  end
467
481
 
468
482
  # Profile - Object Permissions - Grant
469
483
  command :'profile objectPermissions:grant' do |c|
470
- c.syntax = 'mdata profile objectPermissions:grant --profile PROFILE --object OBJECT [options]'
471
- c.summary = 'Grant permissions on an object to a profile'
472
- c.option '--profile PROFILE', String, 'The profile to configure'
473
- c.option '--object OBJECT', String, 'The object to assign permissions for'
474
- c.option '--allowCreate', 'Grant the allowCreate permission'
475
- c.option '--allowEdit', 'Grant the allowEdit permission'
476
- c.option '--allowRead', 'Grant the allowRead permission'
477
- c.option '--allowDelete', 'Grant the allowDelete permission'
478
- c.option '--modifyAllRecords', 'Grant the modifyAllRecords permission'
479
- c.option '--viewAllRecords', 'Grant the viewAllRecords permission'
480
- c.action do |args, opts|
481
- begin
482
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
484
+ c.syntax = 'mdata profile objectPermissions:grant --profile PROFILE --object OBJECT [options]'
485
+ c.summary = 'Grant permissions on an object to a profile'
486
+ c.option '--profile PROFILE', String, 'The profile to configure'
487
+ c.option '--object OBJECT', String, 'The object to assign permissions for'
488
+ c.option '--allowCreate', 'Grant the allowCreate permission'
489
+ c.option '--allowEdit', 'Grant the allowEdit permission'
490
+ c.option '--allowRead', 'Grant the allowRead permission'
491
+ c.option '--allowDelete', 'Grant the allowDelete permission'
492
+ c.option '--modifyAllRecords', 'Grant the modifyAllRecords permission'
493
+ c.option '--viewAllRecords', 'Grant the viewAllRecords permission'
494
+ c.action do |args, opts|
495
+ begin
496
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
483
497
  raise ArgumentError, 'no object specified' if opts.object.nil?
484
498
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
485
499
  idx = profile.objectPermissions.find_index { |x| x.object == opts.object }
@@ -498,27 +512,27 @@ command :'profile objectPermissions:grant' do |c|
498
512
  profile.objectPermissions[idx].modifyAllRecords = 'true' unless opts.modifyAllRecords.nil?
499
513
  profile.objectPermissions[idx].viewAllRecords = 'true' unless opts.viewAllRecords.nil?
500
514
  profile.save
501
- rescue ArgumentError => e
502
- puts "Error executing command: #{e.message}"
503
- end
504
- end
515
+ rescue ArgumentError => e
516
+ puts "Error executing command: #{e.message}"
517
+ end
518
+ end
505
519
  end
506
520
 
507
521
  # Profile - Object Permissions - Revoke
508
522
  command :'profile objectPermissions:revoke' do |c|
509
- c.syntax = 'mdata profile objectPermissions:revoke --profile PROFILE --object OBJECT [options]'
510
- c.summary = 'Revoke permissions on an object from a profile'
511
- c.option '--profile PROFILE', String, 'The profile to configure'
512
- c.option '--object OBJECT', String, 'The object to assign permissions for'
513
- c.option '--allowCreate', 'Revoke the allowCreate permission'
514
- c.option '--allowEdit', 'Revoke the allowEdit permission'
515
- c.option '--allowRead', 'Revoke the allowRead permission'
516
- c.option '--allowDelete', 'Revoke the allowDelete permission'
517
- c.option '--modifyAllRecords', 'Revoke the modifyAllRecords permission'
518
- c.option '--viewAllRecords', 'Revoke the viewAllRecords permission'
519
- c.action do |args, opts|
520
- begin
521
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
523
+ c.syntax = 'mdata profile objectPermissions:revoke --profile PROFILE --object OBJECT [options]'
524
+ c.summary = 'Revoke permissions on an object from a profile'
525
+ c.option '--profile PROFILE', String, 'The profile to configure'
526
+ c.option '--object OBJECT', String, 'The object to assign permissions for'
527
+ c.option '--allowCreate', 'Revoke the allowCreate permission'
528
+ c.option '--allowEdit', 'Revoke the allowEdit permission'
529
+ c.option '--allowRead', 'Revoke the allowRead permission'
530
+ c.option '--allowDelete', 'Revoke the allowDelete permission'
531
+ c.option '--modifyAllRecords', 'Revoke the modifyAllRecords permission'
532
+ c.option '--viewAllRecords', 'Revoke the viewAllRecords permission'
533
+ c.action do |args, opts|
534
+ begin
535
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
522
536
  raise ArgumentError, 'no object specified' if opts.object.nil?
523
537
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
524
538
  idx = profile.objectPermissions.find_index { |x| x.object == opts.object }
@@ -537,59 +551,59 @@ command :'profile objectPermissions:revoke' do |c|
537
551
  profile.objectPermissions[idx].modifyAllRecords = 'false' unless opts.modifyAllRecords.nil?
538
552
  profile.objectPermissions[idx].viewAllRecords = 'false' unless opts.viewAllRecords.nil?
539
553
  profile.save
540
- rescue ArgumentError => e
541
- puts "Error executing command: #{e.message}"
542
- end
543
- end
554
+ rescue ArgumentError => e
555
+ puts "Error executing command: #{e.message}"
556
+ end
557
+ end
544
558
  end
545
559
 
546
560
  # Profile - Object Permissions - Delete
547
561
  command :'profile objectPermissions:delete' do |c|
548
- c.syntax = 'mdata profile objectPermissions:delete --profile PROFILE --object OBJECT'
549
- c.summary = 'Completely removes the permissions for a particular object. Useful if an object is deleted.'
550
- c.option '--profile PROFILE', String, 'The profile to configure'
551
- c.option '--object OBJECT', String, 'The object to delete permissions for'
552
- c.action do |args, opts|
553
- begin
554
- raise ArgumentError, 'no profile specified' if opts.profile.nil?
562
+ c.syntax = 'mdata profile objectPermissions:delete --profile PROFILE --object OBJECT'
563
+ c.summary = 'Completely removes the permissions for a particular object. Useful if an object is deleted.'
564
+ c.option '--profile PROFILE', String, 'The profile to configure'
565
+ c.option '--object OBJECT', String, 'The object to delete permissions for'
566
+ c.action do |args, opts|
567
+ begin
568
+ raise ArgumentError, 'no profile specified' if opts.profile.nil?
555
569
  raise ArgumentError, 'no object specified' if opts.object.nil?
556
570
  profile = Salesforce::Metadata::Profile.read opts.profile, opts.dir
557
571
  profile.objectPermissions.delete_if { |x| x.object == opts.object }
558
572
  profile.save
559
- rescue ArgumentError => e
560
- puts "Error executing command: #{e.message}"
561
- end
562
- end
573
+ rescue ArgumentError => e
574
+ puts "Error executing command: #{e.message}"
575
+ end
576
+ end
563
577
  end
564
578
 
565
579
  # Profile - Object Permissions - Copy
566
580
  command :'profile objectPermissions:copy' do |c|
567
- c.syntax = 'mdata profile objectPermissions:copy --fromProfile PROFILE --toProfile PROFILE --fromObject OBJECT --toObject OBJECT [options]'
568
- c.summary = 'Copies the specified permissions for an object from one profile to another'
569
- c.description = [
570
- 'Copies the permissions on fromProfile for the object fromObject to toObject on toProfile.',
571
- '',
572
- 'If you are copying the permissions from one object to another on the same profile, you can use',
573
- 'the --profile option rather than specifying the same --fromProfile and --toProfile.',
574
- '',
575
- 'Likewise, if you are copying the permissions for an object from one profile to another, you can',
576
- 'specify an --object rather than a --fromObject and --toObject.'
577
- ].join("\n")
578
- c.option '--fromProfile PROFILE', String, 'The source profile'
579
- c.option '--toProfile PROFILE', String, 'The destination profile'
580
- c.option '--profile PROFILE', String, 'A profile to use as the source and destination'
581
- c.option '--fromObject OBJECT', String, 'The source object'
582
- c.option '--toObject OBJECT', String, 'The destination object'
583
- c.option '--object OBJECT', String, 'An object to use as the source and destination'
584
- c.option '--all', 'Copy all permissions'
585
- c.option '--allowCreate', 'Copy the allowCreate permission'
586
- c.option '--allowEdit', 'Copy the allowEdit permission'
587
- c.option '--allowRead', 'Copy the allowRead permission'
588
- c.option '--allowDelete', 'Copy the allowDelete permission'
589
- c.option '--modifyAllRecords', 'Copy the modifyAllRecords permission'
590
- c.option '--viewAllRecords', 'Copy the viewAllRecords permission'
591
- c.action do |args, opts|
592
- # Override options for helper options
581
+ c.syntax = 'mdata profile objectPermissions:copy --fromProfile PROFILE --toProfile PROFILE --fromObject OBJECT --toObject OBJECT [options]'
582
+ c.summary = 'Copies the specified permissions for an object from one profile to another'
583
+ c.description = [
584
+ 'Copies the permissions on fromProfile for the object fromObject to toObject on toProfile.',
585
+ '',
586
+ 'If you are copying the permissions from one object to another on the same profile, you can use',
587
+ 'the --profile option rather than specifying the same --fromProfile and --toProfile.',
588
+ '',
589
+ 'Likewise, if you are copying the permissions for an object from one profile to another, you can',
590
+ 'specify an --object rather than a --fromObject and --toObject.'
591
+ ].join("\n")
592
+ c.option '--fromProfile PROFILE', String, 'The source profile'
593
+ c.option '--toProfile PROFILE', String, 'The destination profile'
594
+ c.option '--profile PROFILE', String, 'A profile to use as the source and destination'
595
+ c.option '--fromObject OBJECT', String, 'The source object'
596
+ c.option '--toObject OBJECT', String, 'The destination object'
597
+ c.option '--object OBJECT', String, 'An object to use as the source and destination'
598
+ c.option '--all', 'Copy all permissions'
599
+ c.option '--allowCreate', 'Copy the allowCreate permission'
600
+ c.option '--allowEdit', 'Copy the allowEdit permission'
601
+ c.option '--allowRead', 'Copy the allowRead permission'
602
+ c.option '--allowDelete', 'Copy the allowDelete permission'
603
+ c.option '--modifyAllRecords', 'Copy the modifyAllRecords permission'
604
+ c.option '--viewAllRecords', 'Copy the viewAllRecords permission'
605
+ c.action do |args, opts|
606
+ # Override options for helper options
593
607
  opts.fromProfile = opts.profile if opts.profile
594
608
  opts.toProfile = opts.profile if opts.profile
595
609
  opts.fromObject = opts.object if opts.object
@@ -600,10 +614,10 @@ command :'profile objectPermissions:copy' do |c|
600
614
  opts.allowDelete = true if opts.all
601
615
  opts.modifyAllRecords = true if opts.all
602
616
  opts.viewAllRecords = true if opts.all
603
-
604
- begin
605
- raise ArgumentError, 'no source profile specified' if opts.fromProfile.nil?
606
- raise ArgumentError, 'no destination profile specified' if opts.toProfile.nil?
617
+
618
+ begin
619
+ raise ArgumentError, 'no source profile specified' if opts.fromProfile.nil?
620
+ raise ArgumentError, 'no destination profile specified' if opts.toProfile.nil?
607
621
  raise ArgumentError, 'no source object specified' if opts.fromObject.nil?
608
622
  raise ArgumentError, 'no destination object specified' if opts.toObject.nil?
609
623
 
@@ -647,10 +661,214 @@ command :'profile objectPermissions:copy' do |c|
647
661
  end
648
662
 
649
663
  to_profile.save
650
- rescue ArgumentError => e
651
- puts "Error executing command: #{e.message}"
652
- end
653
- end
664
+ rescue ArgumentError => e
665
+ puts "Error executing command: #{e.message}"
666
+ end
667
+ end
668
+ end
669
+
670
+ # Permissionset - Field Permissions - Read
671
+ command :'permissionset fieldPermissions:read' do |c|
672
+ c.syntax = 'mdata permissionset fieldPermission:read --permissionset permissionset [options]'
673
+ c.summary = 'See what permissions a particular permissionset is granted'
674
+ c.option '--permissionset PERMISSIONSET', String, 'The permissionset to examine'
675
+ c.option '--field FIELD', String, 'Optionally, a specific field to look for.'
676
+ c.action do |args, opts|
677
+ begin
678
+ raise ArgumentError, 'no permissionset specified' if opts.permissionset.nil?
679
+ permissionset = Salesforce::Metadata::PermissionSet.read opts.permissionset, opts.dir
680
+ permissionset.fieldPermissions.keep_if { |x| x.field == opts.field } unless opts.field.nil?
681
+ permissionset.fieldPermissions.sort! { |a, b| a.field <=> b.field }
682
+ rows = []
683
+ permissionset.fieldPermissions.each do |fp|
684
+ obj = fp.field.split('.')[0]
685
+ field = fp.field.split('.')[1]
686
+ rows << [ obj, field, fp.to_flag_style ]
687
+ end
688
+ table = Terminal::Table.new :rows => rows, :headings => ['Object', 'Field', 'Permissions']
689
+ puts table
690
+ rescue ArgumentError => e
691
+ puts "Error executing command: #{e.message}"
692
+ end
693
+ end
694
+ end
695
+
696
+ # permissionset - Field Permissions - Set
697
+ command :'permissionset fieldPermissions:set' do |c|
698
+ c.syntax = 'mdata permissionset fieldPermissions:set --permissionset permissionset --field FIELD [options]'
699
+ c.summary = 'Overwrites any existing permissions for the field on the permissionset with the ones specified'
700
+ c.option '--permissionset PERMISSIONSET', String, 'The permissionset to configure'
701
+ c.option '--field FIELD', String, 'The field to assign permissions for'
702
+ c.option '--readable', 'Set the read permission'
703
+ c.option '--editable', 'Set the edit permission'
704
+ c.action do |args, opts|
705
+ begin
706
+ raise ArgumentError, 'no permissionset specified' if opts.permissionset.nil?
707
+ raise ArgumentError, 'no field specified' if opts.field.nil?
708
+ permissionset = Salesforce::Metadata::PermissionSet.read opts.permissionset, opts.dir
709
+ idx = permissionset.fieldPermissions.find_index { |x| x.field == opts.field }
710
+
711
+ if idx.nil?
712
+ fp = Salesforce::Types::PermissionSetFieldPermissions.new
713
+ fp.field = opts.field
714
+ permissionset.fieldPermissions.push fp
715
+ idx = permissionset.fieldPermissions.count - 1
716
+ end
717
+
718
+ permissionset.fieldPermissions[idx].readable = case opts.readable
719
+ when nil then 'false'
720
+ else 'true'
721
+ end
722
+ permissionset.fieldPermissions[idx].editable = case opts.editable
723
+ when nil then 'false'
724
+ else 'true'
725
+ end
726
+ permissionset.save
727
+ rescue ArgumentError => e
728
+ puts "Error executing command: #{e.message}"
729
+ end
730
+ end
731
+ end
732
+
733
+ # permissionset - Field Permissions - Grant
734
+ command :'permissionset fieldPermissions:grant' do |c|
735
+ c.syntax = 'mdata permissionset fieldPermissions:grant --permissionset permissionset --field FIELD [options]'
736
+ c.summary = 'Grants the specified permission on the field to the permissionset and leaves all others intact'
737
+ c.option '--permissionset PERMISSIONSET', String, 'The permissionset to configure'
738
+ c.option '--field FIELD', String, 'The field to grant permissions on'
739
+ c.option '--readable', 'Grant the read permission'
740
+ c.option '--editable', 'Grant the edit permission'
741
+ c.action do |args, opts|
742
+ begin
743
+ raise ArgumentError, 'no permissionset specified' if opts.permissionset.nil?
744
+ raise ArgumentError, 'no field specified' if opts.field.nil?
745
+ permissionset = Salesforce::Metadata::PermissionSet.read opts.permissionset, opts.dir
746
+ idx = permissionset.fieldPermissions.find_index { |x| x.field == opts.field }
747
+
748
+ if idx.nil?
749
+ fp = Salesforce::Types::PermissionSetFieldPermissions.new
750
+ fp.field = opts.field
751
+ permissionset.fieldPermissions.push fp
752
+ idx = permissionset.fieldPermissions.count - 1
753
+ end
754
+
755
+ permissionset.fieldPermissions[idx].readable = 'true' unless opts.readable.nil?
756
+ permissionset.fieldPermissions[idx].editable = 'true' unless opts.editable.nil?
757
+ permissionset.save
758
+ rescue ArgumentError => e
759
+ puts "Error executing command: #{e.message}"
760
+ end
761
+ end
762
+ end
763
+
764
+ # permissionset - Field Permissions - Revoke
765
+ command :'permissionset fieldPermissions:revoke' do |c|
766
+ c.syntax = 'mdata permissionset fieldPermissions:revoke --permissionset permissionset --field FIELD [options]'
767
+ c.summary = 'Revokes the specified permission on the field to the permissionset and leaves all others intact'
768
+ c.option '--permissionset PERMISSIONSET', String, 'The permissionset to configure'
769
+ c.option '--field FIELD', String, 'The field to revoke permissions on'
770
+ c.option '--readable', 'Revoke the read permission'
771
+ c.option '--editable', 'Revoke the edit permission'
772
+ c.action do |args, opts|
773
+ begin
774
+ raise ArgumentError, 'no permissionset specified' if opts.permissionset.nil?
775
+ raise ArgumentError, 'no field specified' if opts.field.nil?
776
+ permissionset = Salesforce::Metadata::PermissionSet.read opts.permissionset, opts.dir
777
+ idx = permissionset.fieldPermissions.find_index { |x| x.field == opts.field }
778
+ raise ArgumentError, 'field not found in permissionset' if idx.nil?
779
+ permissionset.fieldPermissions[idx].readable = 'false' unless opts.readable.nil?
780
+ permissionset.fieldPermissions[idx].editable = 'false' unless opts.editable.nil?
781
+ permissionset.save
782
+ rescue ArgumentError => e
783
+ puts "Error executing command: #{e.message}"
784
+ end
785
+ end
786
+ end
787
+
788
+ # permissionset - Field Permissions - Copy
789
+ command :'permissionset fieldPermissions:copy' do |c|
790
+ c.syntax = 'mdata permissionset fieldPermissions:copy --fromPermissionset PERMISSIONSET --toPermissionset PERMISSIONSET --fromField FIELD --toField FIELD [options]'
791
+ c.summary = 'Copies the specified permissions for a field from one permissionset to another'
792
+ c.description = [
793
+ 'Copies the permissions on fromPermissionset for the object fromField to toField on toPermissionset.',
794
+ '',
795
+ 'If you are copying the permissions from one field to another on the same permissionset, you can use',
796
+ 'the --permissionset option rather than specifying the same --fromPermissionset and --toPermissionset.',
797
+ '',
798
+ 'Likewise, if you are copying the permissions for an field from one permissionset to another, you can',
799
+ 'specify an --field rather than a --fromField and --toField.'
800
+ ].join("\n")
801
+ c.option '--fromPermissionset PERMISSIONSET', String, 'The source permissionset'
802
+ c.option '--toPermissionset PERMISSIONSET', String, 'The destination permissionset'
803
+ c.option '--permissionset PERMISSIONSET', String, 'A permissionset to use as the source and destination'
804
+ c.option '--fromField FIELD', String, 'The source field'
805
+ c.option '--toField FIELD', String, 'The destination field'
806
+ c.option '--field FIELD', String, 'A field to use as the source and destination'
807
+ c.option '--all', 'Copy all permissions'
808
+ c.option '--readable', 'Copy the read permission'
809
+ c.option '--editable', 'Copy the edit permission'
810
+ c.action do |args, opts|
811
+ # Override options for helper options
812
+ opts.fromPermissionset = opts.permissionset if opts.permissionset
813
+ opts.toPermissionset = opts.permissionset if opts.permissionset
814
+ opts.fromField = opts.field if opts.field
815
+ opts.toField = opts.field if opts.field
816
+ opts.readable = true if opts.all
817
+ opts.editable = true if opts.all
818
+
819
+ begin
820
+ raise ArgumentError, 'no source permissionset specified' if opts.fromPermissionset.nil?
821
+ raise ArgumentError, 'no destination permissionset specified' if opts.toPermissionset.nil?
822
+ raise ArgumentError, 'no source field specified' if opts.fromField.nil?
823
+ raise ArgumentError, 'no destination field specified' if opts.toField.nil?
824
+
825
+ from_permissionset = Salesforce::Metadata::PermissionSet.read opts.fromPermissionset, opts.dir
826
+ src_idx = from_permissionset.fieldPermissions.find_index { |x| x.field == opts.fromField }
827
+ raise ArgumentError, 'source field not found in source permissionset' if src_idx.nil?
828
+
829
+ to_permissionset = Salesforce::Metadata::PermissionSet.read opts.toPermissionset, opts.dir
830
+ dst_idx = to_permissionset.fieldPermissions.find_index { |x| x.field == opts.toField }
831
+
832
+ if dst_idx.nil?
833
+ fp = Salesforce::Types::PermissionSetFieldPermissions.new
834
+ fp.field = opts.toField
835
+ to_permissionset.fieldPermissions.push fp
836
+ dst_idx = to_permissionset.fieldPermissions.count - 1
837
+ end
838
+
839
+ unless opts.readable.nil?
840
+ val = from_permissionset.fieldPermissions[src_idx].readable
841
+ to_permissionset.fieldPermissions[dst_idx].readable = val
842
+ end
843
+ unless opts.editable.nil?
844
+ val = from_permissionset.fieldPermissions[src_idx].editable
845
+ to_permissionset.fieldPermissions[dst_idx].editable = val
846
+ end
847
+
848
+ to_permissionset.save
849
+ rescue ArgumentError => e
850
+ puts "Error executing command: #{e.message}"
851
+ end
852
+ end
853
+ end
854
+
855
+ # permissionset - Field Permissions - Revoke
856
+ command :'permissionset fieldPermissions:delete' do |c|
857
+ c.syntax = 'mdata permissionset fieldPermissions:delete --permissionset permissionset --field FIELD'
858
+ c.summary = 'Completely removes the permissions for a particular field. Useful if a field is deleted from an object.'
859
+ c.option '--permissionset PERMISSIONSET', String, 'The permissionset to configure'
860
+ c.option '--field FIELD', String, 'The field to revoke permissions on'
861
+ c.action do |args, opts|
862
+ begin
863
+ raise ArgumentError, 'no permissionset specified' if opts.permissionset.nil?
864
+ raise ArgumentError, 'no field specified' if opts.field.nil?
865
+ permissionset = Salesforce::Metadata::PermissionSet.read opts.permissionset, opts.dir
866
+ permissionset.fieldPermissions.delete_if { |x| x.field == opts.field }
867
+ permissionset.save
868
+ rescue ArgumentError => e
869
+ puts "Error executing command: #{e.message}"
870
+ end
871
+ end
654
872
  end
655
873
 
656
874
  alias_command :'pr fp:r', :'profile fieldPermissions:read'
@@ -672,3 +890,10 @@ alias_command :'pr op:g', :'profile objectPermissions:grant'
672
890
  alias_command :'pr op:v', :'profile objectPermissions:revoke'
673
891
  alias_command :'pr op:c', :'profile objectPermissions:copy'
674
892
  alias_command :'pr op:d', :'profile objectPermissions:delete'
893
+
894
+ alias_command :'ps fp:r', :'permissionset fieldPermissions:read'
895
+ alias_command :'ps fp:s', :'permissionset fieldPermissions:set'
896
+ alias_command :'ps fp:g', :'permissionset fieldPermissions:grant'
897
+ alias_command :'ps fp:v', :'permissionset fieldPermissions:revoke'
898
+ alias_command :'ps fp:c', :'permissionset fieldPermissions:copy'
899
+ alias_command :'ps fp:d', :'permissionset fieldPermissions:delete'
@@ -0,0 +1,109 @@
1
+ require 'roxml'
2
+ require 'nokogiri'
3
+ require 'mdata/types'
4
+
5
+ module Salesforce
6
+ module Metadata
7
+ # A Salesforce PermissionSet metadata object.
8
+ #
9
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_permissionset.htm
10
+ #
11
+ # @author Ben Burwell
12
+ class PermissionSet
13
+ include ROXML
14
+
15
+ attr_accessor :filename
16
+
17
+ xml_name 'PermissionSet'
18
+
19
+
20
+ xml_accessor :applicationVisibilities,
21
+ as: [Salesforce::Types::PermissionSetApplicationVisibility],
22
+ from: 'applicationVisibilities'
23
+
24
+ xml_accessor :classAccesses,
25
+ as: [Salesforce::Types::PermissionSetApexClassAccess],
26
+ from: 'classAccesses'
27
+
28
+ xml_accessor :customPermissions,
29
+ as: [Salesforce::Types::PermissionSetCustomPermissions],
30
+ from: 'customPermissions'
31
+
32
+ xml_accessor :description
33
+
34
+ xml_accessor :externalDataSourceAccesses,
35
+ as: [Salesforce::Types::PermissionSetExternalDataSourceAccess],
36
+ from: 'externalDataSourceAccesses'
37
+
38
+ xml_accessor :fieldPermissions,
39
+ as: [Salesforce::Types::PermissionSetFieldPermissions],
40
+ from: 'fieldPermissions'
41
+
42
+ xml_accessor :label
43
+
44
+ xml_accessor :objectPermissions,
45
+ as: [Salesforce::Types::PermissionSetObjectPermissions],
46
+ from: 'objectPermissions'
47
+
48
+ xml_accessor :pageAccesses,
49
+ as: [Salesforce::Types::PermissionSetApexPageAccess],
50
+ from: 'pageAccesses'
51
+
52
+ xml_accessor :recordTypeVisibilities,
53
+ as: [Salesforce::Types::PermissionSetRecordTypeVisibility],
54
+ from: 'recordTypeVisibilities'
55
+
56
+ xml_accessor :tabSettings,
57
+ as: [Salesforce::Types::PermissionSetTabSetting],
58
+ from: 'tabSettings'
59
+
60
+ xml_accessor :userLicense
61
+
62
+ xml_accessor :userPermissions,
63
+ as: [Salesforce::Types::PermissionSetUserPermission],
64
+ from: 'userPermissions'
65
+
66
+ # Read a permissionset file from its name and directory
67
+ #
68
+ # The default file path is `./src/permissionsets/NAME.permissionset`, but the
69
+ # directory can be overridden by passing a non-nil String.
70
+ #
71
+ # @param name [String] the name of the permissionset to read, like 'Admin'
72
+ # @param dir [String] the directory to search for the permissionset in. If
73
+ # nil, defaults to `./src/permissionsets`.
74
+ # @return [PermissionSet] the permissionset object that has been instantiated
75
+ def self.read name, dir
76
+ dir = './src/permissionsets' if dir.nil?
77
+ filename = "#{dir}/#{name}.permissionset"
78
+ permissionset = PermissionSet.from_xml(File.read(filename))
79
+ permissionset.filename = filename
80
+ permissionset
81
+ end
82
+
83
+ # Save the permissionset to disk, writing it to the file from whence it came
84
+ #
85
+ # Relies on the permissionset object having a `@filename` to save to.
86
+ def save
87
+ doc = ::Nokogiri::XML::Document.new
88
+ doc.root = to_xml()
89
+ doc.root.add_namespace nil, 'http://soap.sforce.com/2006/04/metadata'
90
+ File.open @filename, 'w' do |file|
91
+ file << doc.serialize
92
+ end
93
+ end
94
+
95
+ # Create an empty permissionset by name in directory
96
+ #
97
+ # @param name [String] the name of the permissionset to create
98
+ # @param dir [String] the directory to create it in, defaulting to
99
+ # `./src/permissionsets`.
100
+ def self.touch name, dir
101
+ dir = './src/permissionsets' if dir.nil?
102
+ filename = "#{dir}/#{name}.permissionset"
103
+ permissionset = PermissionSet.new
104
+ permissionset.filename = filename
105
+ permissionset.save
106
+ end
107
+ end
108
+ end
109
+ end
@@ -1,3 +1,4 @@
1
+ require 'mdata/metadata/PermissionSet'
1
2
  require 'mdata/metadata/Profile'
2
3
 
3
4
  module Salesforce
@@ -15,5 +15,6 @@ module Salesforce
15
15
 
16
16
  # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileApexClassAccess_title
17
17
  class ProfileApexClassAccess < ApexClassAccess; end
18
+ class PermissionSetApexClassAccess < ApexClassAccess; end
18
19
  end
19
20
  end
@@ -15,5 +15,6 @@ module Salesforce
15
15
 
16
16
  # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileApexPageAccess_title
17
17
  class ProfileApexPageAccess < ApexPageAccess; end
18
+ class PermissionSetApexPageAccess < ApexPageAccess; end
18
19
  end
19
20
  end
@@ -10,11 +10,14 @@ module Salesforce
10
10
  include ROXML
11
11
 
12
12
  xml_accessor :application
13
- xml_accessor :default
14
13
  xml_accessor :visible
15
14
  end
16
15
 
17
16
  # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileapplicationvisibility_title
18
- class ProfileApplicationVisibility < ApplicationVisibility; end
17
+ class ProfileApplicationVisibility < ApplicationVisibility
18
+ xml_accessor :default
19
+ end
20
+
21
+ class PermissionSetApplicationVisibility < ApplicationVisibility; end
19
22
  end
20
23
  end
@@ -15,5 +15,6 @@ module Salesforce
15
15
 
16
16
  # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#ProfileCustomPermissions_title
17
17
  class ProfileCustomPermissions < CustomPermissions; end
18
+ class PermissionSetCustomPermissions < CustomPermissions; end
18
19
  end
19
20
  end
@@ -15,5 +15,6 @@ module Salesforce
15
15
 
16
16
  # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileExternalDataSourceAccess_title
17
17
  class ProfileExternalDataSourceAccess < ExternalDataSourceAccess; end
18
+ class PermissionSetExternalDataSourceAccess < ExternalDataSourceAccess; end
18
19
  end
19
20
  end
@@ -0,0 +1,19 @@
1
+ require 'roxml'
2
+
3
+ module Salesforce
4
+ module Types
5
+ # A generic FieldPermissions class that can be extended for specific
6
+ # metadata objects, e.g. PermissionSetFieldPermissions.
7
+ #
8
+ # @author Ben Burwell
9
+ class FieldPermissions
10
+ include ROXML
11
+
12
+ xml_accessor :editable
13
+ xml_accessor :field
14
+ xml_accessor :readable
15
+ end
16
+
17
+ class PermissionSetFieldPermissions < FieldPermissions; end
18
+ end
19
+ end
@@ -81,5 +81,7 @@ module Salesforce
81
81
 
82
82
  # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileobjectpermissions_title
83
83
  class ProfileObjectPermissions < ObjectPermissions; end
84
+
85
+ class PermissionSetObjectPermissions < ObjectPermissions; end
84
86
  end
85
87
  end
@@ -9,13 +9,15 @@ module Salesforce
9
9
  class RecordTypeVisibility
10
10
  include ROXML
11
11
 
12
- xml_accessor :default
13
- xml_accessor :personAccountDefault
14
12
  xml_accessor :recordType
15
13
  xml_accessor :visible
16
14
  end
17
15
 
18
16
  # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profilerecordtypevisibility_title
19
- class ProfileRecordTypeVisibility < RecordTypeVisibility; end
17
+ class ProfileRecordTypeVisibility < RecordTypeVisibility
18
+ xml_accessor :default
19
+ xml_accessor :personAccountDefault
20
+ end
21
+ class PermissionSetRecordTypeVisibility < RecordTypeVisibility; end
20
22
  end
21
23
  end
@@ -0,0 +1,18 @@
1
+ require 'roxml'
2
+
3
+ module Salesforce
4
+ module Types
5
+ # A generic TabSetting class that can be extended for specific
6
+ # metadata objects, e.g. PermissionSetTabSetting.
7
+ #
8
+ # @author Ben Burwell
9
+ class TabSetting
10
+ include ROXML
11
+
12
+ xml_accessor :tab
13
+ xml_accessor :visibility # enum: Available, None, Hidden
14
+ end
15
+
16
+ class PermissionSetTabSetting < TabSetting; end
17
+ end
18
+ end
@@ -15,5 +15,6 @@ module Salesforce
15
15
 
16
16
  # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileUserPerm_title
17
17
  class ProfileUserPermission < UserPermission; end
18
+ class PermissionSetUserPermission < UserPermission; end
18
19
  end
19
20
  end
data/lib/mdata/types.rb CHANGED
@@ -3,12 +3,14 @@ require 'mdata/types/ApexClassAccess'
3
3
  require 'mdata/types/CustomPermissions'
4
4
  require 'mdata/types/ExternalDataSourceAccess'
5
5
  require 'mdata/types/FieldLevelSecurity'
6
+ require 'mdata/types/FieldPermissions'
6
7
  require 'mdata/types/LayoutAssignments'
7
8
  require 'mdata/types/LoginHours'
8
9
  require 'mdata/types/LoginIpRange'
9
10
  require 'mdata/types/ObjectPermissions'
10
11
  require 'mdata/types/ApexPageAccess'
11
12
  require 'mdata/types/RecordTypeVisibility'
13
+ require 'mdata/types/TabSetting'
12
14
  require 'mdata/types/TabVisibility'
13
15
  require 'mdata/types/UserPermission'
14
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Burwell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2015-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -63,19 +63,22 @@ files:
63
63
  - README.markdown
64
64
  - lib/mdata.rb
65
65
  - lib/mdata/metadata.rb
66
+ - lib/mdata/metadata/PermissionSet.rb
66
67
  - lib/mdata/metadata/Profile.rb
67
68
  - lib/mdata/types.rb
68
- - lib/mdata/types/ApplicationVisibility.rb
69
69
  - lib/mdata/types/ApexClassAccess.rb
70
+ - lib/mdata/types/ApexPageAccess.rb
71
+ - lib/mdata/types/ApplicationVisibility.rb
70
72
  - lib/mdata/types/CustomPermissions.rb
71
73
  - lib/mdata/types/ExternalDataSourceAccess.rb
72
74
  - lib/mdata/types/FieldLevelSecurity.rb
75
+ - lib/mdata/types/FieldPermissions.rb
73
76
  - lib/mdata/types/LayoutAssignments.rb
74
77
  - lib/mdata/types/LoginHours.rb
75
78
  - lib/mdata/types/LoginIpRange.rb
76
79
  - lib/mdata/types/ObjectPermissions.rb
77
- - lib/mdata/types/ApexPageAccess.rb
78
80
  - lib/mdata/types/RecordTypeVisibility.rb
81
+ - lib/mdata/types/TabSetting.rb
79
82
  - lib/mdata/types/TabVisibility.rb
80
83
  - lib/mdata/types/UserPermission.rb
81
84
  - bin/mdata