mdata 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mdata +148 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f7283c8242cfdcae92ef9b93bb061e6307fc6ec
|
4
|
+
data.tar.gz: d60882e942171bd126e7c921bbc87346b6ee3052
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24d038f1f3a656007ed6b0f2ac4e714609d843aed40f4d7b16a5224353e81a7e9663721c497d84d96ff160ce8b5c90a955062a485942b1ad27334895cee1f137
|
7
|
+
data.tar.gz: d82ee3e7cec83d33a8d746137fdd9d5974e5531c396fb34fc1cac9a9427ec004acdb14dde5d0da20b2761087bb37b4fed2abf55ffa6bf5c567e383c555c013eb
|
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.
|
8
|
+
program :version, '1.4.0'
|
9
9
|
program :description, 'Your Salesforce metadata navigator and manipulator'
|
10
10
|
program :help, 'Author', 'Ben Burwell <ben.burwell@trifecta.com>'
|
11
11
|
|
@@ -871,6 +871,147 @@ command :'permissionset fieldPermissions:delete' do |c|
|
|
871
871
|
end
|
872
872
|
end
|
873
873
|
|
874
|
+
# Permissionset - Class Access - Read
|
875
|
+
command :'permissionset classAccess:read' do |c|
|
876
|
+
c.syntax = 'mdata permissionset classAccess:read --permissionset PERMISSIONSET [options]'
|
877
|
+
c.summary = 'View Apex class access for a permission set'
|
878
|
+
c.option '--permissionset PERMISSIONSET', String, 'The permission set to read'
|
879
|
+
c.option '--class CLASS', String, 'Optionally, a particular class to look for'
|
880
|
+
c.action do |args, opts|
|
881
|
+
begin
|
882
|
+
raise ArgumentError, 'no permission set specified' if opts.permissionset.nil?
|
883
|
+
permissionset = Salesforce::Metadata::PermissionSet.read opts.permissionset, opts.dir
|
884
|
+
permissionset.classAccesses.keep_if { |x| x.apexClass == opts.class } unless opts.class.nil?
|
885
|
+
permissionset.classAccesses.sort! { |a, b| a.apexClass <=> b.apexClass }
|
886
|
+
rows = []
|
887
|
+
permissionset.classAccesses.each do |cls|
|
888
|
+
rows << [ cls.apexClass, cls.enabled ]
|
889
|
+
end
|
890
|
+
table = Terminal::Table.new :rows => rows, :headings => ['Class', 'Enabled']
|
891
|
+
puts table
|
892
|
+
rescue ArgumentError => e
|
893
|
+
puts "Error executing command: #{e.message}"
|
894
|
+
end
|
895
|
+
end
|
896
|
+
end
|
897
|
+
|
898
|
+
# Permissionset - Class Access - Grant
|
899
|
+
command :'permissionset classAccess:grant' do |c|
|
900
|
+
c.syntax = 'mdata permissionset classAccess:grant --permissionset PERMISSIONSET --class CLASS [options]'
|
901
|
+
c.summary = 'Grant Apex class access for a permissionset'
|
902
|
+
c.option '--permissionset PERMISSIONSET', String, 'The permissionset to grant access on'
|
903
|
+
c.option '--class CLASS', String, 'The class to grant access to'
|
904
|
+
c.action do |args, opts|
|
905
|
+
begin
|
906
|
+
raise ArgumentError, 'no permissionset specified' if opts.permissionset.nil?
|
907
|
+
raise ArgumentError, 'no class specified' if opts.class.nil?
|
908
|
+
permissionset = Salesforce::Metadata::PermissionSet.read opts.permissionset, opts.dir
|
909
|
+
idx = permissionset.classAccesses.find_index { |x| x.apexClass == opts.class }
|
910
|
+
if idx.nil?
|
911
|
+
ca = Salesforce::Types::PermissionSetApexClassAccess.new
|
912
|
+
ca.apexClass = opts.class
|
913
|
+
permissionset.classAccesses.push ca
|
914
|
+
idx = permissionset.classAccesses.count - 1
|
915
|
+
end
|
916
|
+
permissionset.classAccesses[idx].enabled = 'true'
|
917
|
+
permissionset.save
|
918
|
+
rescue ArgumentError => e
|
919
|
+
puts "Error executing command: #{e.message}"
|
920
|
+
end
|
921
|
+
end
|
922
|
+
end
|
923
|
+
|
924
|
+
# Permissionset - Class Access - Disable
|
925
|
+
command :'permissionset classAccess:revoke' do |c|
|
926
|
+
c.syntax = 'mdata permissionset classAccess:revoke --permissionset PERMISSIONSET --class CLASS [options]'
|
927
|
+
c.summary = 'Revoke Apex class access for a permissionset'
|
928
|
+
c.option '--permissionset PERMISSIONSET', String, 'The permissionset to revoke access on'
|
929
|
+
c.option '--class CLASS', String, 'The class to revoke access to'
|
930
|
+
c.action do |args, opts|
|
931
|
+
begin
|
932
|
+
raise ArgumentError, 'no permissionset specified' if opts.permissionset.nil?
|
933
|
+
raise ArgumentError, 'no class specified' if opts.class.nil?
|
934
|
+
permissionset = Salesforce::Metadata::PermissionSet.read opts.permissionset, opts.dir
|
935
|
+
idx = permissionset.classAccesses.find_index { |x| x.apexClass == opts.class }
|
936
|
+
if idx.nil?
|
937
|
+
ca = Salesforce::Types::PermissionSetApexClassAccess.new
|
938
|
+
ca.apexClass = opts.class
|
939
|
+
permissionset.classAccesses.push ca
|
940
|
+
idx = permissionset.classAccesses.count - 1
|
941
|
+
end
|
942
|
+
permissionset.classAccesses[idx].enabled = 'false'
|
943
|
+
permissionset.save
|
944
|
+
rescue ArgumentError => e
|
945
|
+
puts "Error executing command: #{e.message}"
|
946
|
+
end
|
947
|
+
end
|
948
|
+
end
|
949
|
+
|
950
|
+
# Permissionset - Class Access - Delete
|
951
|
+
command :'permissionset classAccess:delete' do |c|
|
952
|
+
c.syntax = 'mdata permissionset classAccess:delete --permissionset PERMISSIONSET --class CLASS [options]'
|
953
|
+
c.summary = 'Delete Apex class access for a permissionset'
|
954
|
+
c.option '--permissionset PERMISSIONSET', String, 'The permissionset to delete access on'
|
955
|
+
c.option '--class CLASS', String, 'The class to delete access to'
|
956
|
+
c.action do |args, opts|
|
957
|
+
begin
|
958
|
+
raise ArgumentError, 'no permissionset specified' if opts.permissionset.nil?
|
959
|
+
raise ArgumentError, 'no class specified' if opts.class.nil?
|
960
|
+
permissionset = Salesforce::Metadata::PermissionSet.read opts.permissionset, opts.dir
|
961
|
+
permissionset.classAccesses.delete_if { |x| x.apexClass == opts.class }
|
962
|
+
permissionset.save
|
963
|
+
rescue ArgumentError => e
|
964
|
+
puts "Error executing command: #{e.message}"
|
965
|
+
end
|
966
|
+
end
|
967
|
+
end
|
968
|
+
|
969
|
+
# Permissionset - Class Access - Copy
|
970
|
+
command :'permissionset classAccess:copy' do |c|
|
971
|
+
c.syntax = 'mdata permissionset classAccess:copy [options]'
|
972
|
+
c.summary = 'Copy class access from one class to another or one permissionset to another.'
|
973
|
+
c.option '--fromPermissionset permissionset', String, 'The permissionset to copy from'
|
974
|
+
c.option '--toPermissionset permissionset', String, 'The permissionset to copy to'
|
975
|
+
c.option '--permissionset PERMISSIONSET', String, 'A shortcut for specifying the same source and destination permissionset'
|
976
|
+
c.option '--fromClass CLASS', String, 'The class to copy from'
|
977
|
+
c.option '--toClass CLASS', String, 'The class to copy to'
|
978
|
+
c.option '--class CLASS', String, 'A shortcut for specifying the same source and destination class'
|
979
|
+
c.action do |args, opts|
|
980
|
+
opts.fromPermissionset = opts.permissionset unless opts.permissionset.nil?
|
981
|
+
opts.toPermissionset = opts.permissionset unless opts.permissionset.nil?
|
982
|
+
opts.fromClass = opts.class unless opts.class.nil?
|
983
|
+
opts.toClass = opts.class unless opts.class.nil?
|
984
|
+
|
985
|
+
begin
|
986
|
+
raise ArgumentError, 'no source permissionset' if opts.fromPermissionset.nil?
|
987
|
+
raise ArgumentError, 'no destination permissionset' if opts.toPermissionset.nil?
|
988
|
+
raise ArgumentError, 'no source class' if opts.fromClass.nil?
|
989
|
+
raise ArgumentError, 'no destination class' if opts.toClass.nil?
|
990
|
+
|
991
|
+
from_permissionset = Salesforce::Metadata::PermissionSet.read opts.fromPermissionset, opts.dir
|
992
|
+
src_idx = from_permissionset.classAccesses.find_index { |x| x.apexClass == opts.fromClass }
|
993
|
+
raise ArgumentError, 'source class not found in source permissionset' if src_idx.nil?
|
994
|
+
|
995
|
+
to_permissionset = Salesforce::Metadata::PermissionSet.read opts.toPermissionset, opts.dir
|
996
|
+
dst_idx = to_permissionset.classAccesses.find_index { |x| x.apexClass == opts.toClass }
|
997
|
+
|
998
|
+
if dst_idx.nil?
|
999
|
+
ca = Salesforce::Types::PermissionSetApexClassAccess.new
|
1000
|
+
ca.apexClass = opts.toClass
|
1001
|
+
to_permissionset.classAccesses.push ca
|
1002
|
+
dst_idx = to_permissionset.classAccesses.count - 1
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
val = from_permissionset.classAccesses[src_idx]
|
1006
|
+
to_permissionset.classAccesses[dst_idx] = val
|
1007
|
+
|
1008
|
+
to_permissionset.save
|
1009
|
+
rescue ArgumentError => e
|
1010
|
+
puts "Error executing command: #{e.message}"
|
1011
|
+
end
|
1012
|
+
end
|
1013
|
+
end
|
1014
|
+
|
874
1015
|
alias_command :'pr fp:r', :'profile fieldPermissions:read'
|
875
1016
|
alias_command :'pr fp:s', :'profile fieldPermissions:set'
|
876
1017
|
alias_command :'pr fp:g', :'profile fieldPermissions:grant'
|
@@ -897,3 +1038,9 @@ alias_command :'ps fp:g', :'permissionset fieldPermissions:grant'
|
|
897
1038
|
alias_command :'ps fp:v', :'permissionset fieldPermissions:revoke'
|
898
1039
|
alias_command :'ps fp:c', :'permissionset fieldPermissions:copy'
|
899
1040
|
alias_command :'ps fp:d', :'permissionset fieldPermissions:delete'
|
1041
|
+
|
1042
|
+
alias_command :'ps ca:r', :'permissionset classAccess:read'
|
1043
|
+
alias_command :'ps ca:g', :'permissionset classAccess:grant'
|
1044
|
+
alias_command :'ps ca:v', :'permissionset classAccess:revoke'
|
1045
|
+
alias_command :'ps ca:d', :'permissionset classAccess:delete'
|
1046
|
+
alias_command :'ps ca:c', :'permissionset classAccess:copy'
|
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.
|
4
|
+
version: 1.4.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-10-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|