sf_cli 0.0.7.beta2 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +39 -115
  3. data/lib/sf_cli/console/commands.rb +36 -0
  4. data/lib/sf_cli/console.rb +5 -0
  5. data/lib/sf_cli/sf/apex/core.rb +18 -0
  6. data/lib/sf_cli/sf/apex/run.rb +113 -0
  7. data/lib/sf_cli/sf/core/base.rb +1 -0
  8. data/lib/sf_cli/sf/data/bulk_result_v2.rb +2 -3
  9. data/lib/sf_cli/sf/data/core.rb +5 -6
  10. data/lib/sf_cli/sf/data/create_record.rb +6 -8
  11. data/lib/sf_cli/sf/data/delete_bulk.rb +9 -10
  12. data/lib/sf_cli/sf/data/delete_record.rb +8 -9
  13. data/lib/sf_cli/sf/data/delete_resume.rb +7 -9
  14. data/lib/sf_cli/sf/data/get_record.rb +11 -13
  15. data/lib/sf_cli/sf/data/helper_methods.rb +1 -0
  16. data/lib/sf_cli/sf/data/query.rb +20 -27
  17. data/lib/sf_cli/sf/data/query_helper.rb +3 -0
  18. data/lib/sf_cli/sf/data/resume.rb +6 -6
  19. data/lib/sf_cli/sf/data/search.rb +9 -10
  20. data/lib/sf_cli/sf/data/update_record.rb +11 -14
  21. data/lib/sf_cli/sf/data/upsert_bulk.rb +9 -12
  22. data/lib/sf_cli/sf/data/upsert_resume.rb +7 -10
  23. data/lib/sf_cli/sf/main.rb +8 -4
  24. data/lib/sf_cli/sf/model/base_methods.rb +1 -0
  25. data/lib/sf_cli/sf/model/class_definition.rb +1 -0
  26. data/lib/sf_cli/sf/model/dml_methods.rb +1 -0
  27. data/lib/sf_cli/sf/model/generator.rb +2 -1
  28. data/lib/sf_cli/sf/model/query_condition.rb +2 -1
  29. data/lib/sf_cli/sf/model/query_methods.rb +1 -0
  30. data/lib/sf_cli/sf/model/sf_command_connection.rb +24 -5
  31. data/lib/sf_cli/sf/model.rb +6 -4
  32. data/lib/sf_cli/sf/org/core.rb +6 -6
  33. data/lib/sf_cli/sf/org/display.rb +7 -6
  34. data/lib/sf_cli/sf/org/list.rb +12 -13
  35. data/lib/sf_cli/sf/org/login.rb +22 -28
  36. data/lib/sf_cli/sf/project/core.rb +10 -72
  37. data/lib/sf_cli/sf/project/generate.rb +35 -0
  38. data/lib/sf_cli/sf/project/generate_manifest.rb +31 -0
  39. data/lib/sf_cli/sf/sobject/core.rb +10 -47
  40. data/lib/sf_cli/sf/sobject/describe.rb +29 -0
  41. data/lib/sf_cli/sf/sobject/list.rb +18 -0
  42. data/lib/sf_cli.rb +5 -12
  43. metadata +11 -8
  44. data/CHANGELOG.md +0 -55
  45. data/bin/sfc +0 -7
  46. data/lib/sf_cli/sf/console.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfe11b6577f9c950bc7ebe9a602392f843462d2121e4b53bad470ae5fc88d70a
4
- data.tar.gz: 7b8be5a7d4d7fe214968a41ed334df490c59fec0c1308c922b98c53d7e6d5bc4
3
+ metadata.gz: fa13644d7e9281efbbb57516775a5edd9b69fb7ff9fbc260332a54d0afebc227
4
+ data.tar.gz: feb9c574b8d0681fbe9ba43572cb9b7725558fc20f69eebbbd3a2b3734aa60b9
5
5
  SHA512:
6
- metadata.gz: e5dd28989b46ed7044bf01f872197f29a591b005e0d150dd526c97d2c5fdf1e543a7112d3ccdff5867f967800f1673f2073a0585bb06223d8b541f8ac2ae2873
7
- data.tar.gz: 25a31b68eed96337d806721c42c24ad1452728c00f2db8577c93f211a2147fab61c9a8b692978f67df8b690ea8aa94bbf21fea5200e8b6ac4c1c2ad71062474b
6
+ metadata.gz: ade35b3acd147ac13367c6d681c31028fef4b661ab2a97101e21b170221231c81c8d76a13c9e6f2688b085ae4889c8872ced4dd72b4f1d21cc8ac465cde78096
7
+ data.tar.gz: f7fb45fc3c50d2ab557f82d28b74119465fddad2c5930710aadbe0b44c19da49b8ac76c6815f0e18132d0f49d1590ed456ed42069ca07385e75db3d630f0812e
data/README.rdoc CHANGED
@@ -5,137 +5,61 @@ This is a class library for introducing {Salesforce CLI}[https://developer.sales
5
5
  It is designed to be similar usability to the original command.<br>
6
6
  Currently only *sf* command is the target of development.
7
7
 
8
+ [rubygems] https://rubygems.org/gems/sf_cli
9
+ [official document] https://tmkw.github.io/sf_cli/
10
+
8
11
  == prerequisite
9
- Salesforce CLI must be installed.<br>
12
+ {Salesforce CLI}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_top.htm] must be installed.<br>
10
13
  As of as of September in 2024, ver.2.56.7 is the development target.
11
14
 
12
15
  == install
13
- ==== Rubygem
14
- $ gem install sf_cli
15
-
16
- ==== Bundler
17
- in Gemfile:
18
- gem 'sf_cli'
19
-
20
- then,
21
- $ bundle install
22
-
23
- == Examples
24
- === Since 0.0.4
16
+ Rubygem::
17
+ the simplest way:
18
+ $ gem install sf_cli
19
+ Bundler::
20
+ in Gemfile:
21
+ gem 'sf_cli'
22
+ then,
23
+ $ bundle install
24
+ == Usage
25
+ Load module
25
26
  require 'sf_cli'
26
27
 
27
- # login to org
28
+ Login to org
28
29
  sf.org.login_web
29
30
 
30
- # get records
31
- sf.data.query 'SELECT Id, Name FROM Account LIMIT 1' # => [{Id: "abc", Name: "account name"}]
32
-
33
- # generate a Salesforce DX project
34
- sf.project.generate 'MyProject'
35
-
36
- === Before 0.0.3
37
- require 'sf_cli/sf'
31
+ Get Salesforce Object schema
32
+ sf.sobject.describe :Account
38
33
 
39
- sf = SfCli::Sf.new
34
+ Get a record
35
+ sf.data.get_record :Account, record_id: 'xxxxxxx'
36
+ sf.data.get_record :Account, where: {Name: 'Jonny B.Good', Country: 'USA'}
40
37
 
41
- # login to org
42
- sf.org.login_web
38
+ Execute SOQL
39
+ sf.data.query "SELECT Id, Name FROM Account LIMIT 1" # => [{Id: "abc", Name: "account name"}]
43
40
 
44
- # get Account records
45
- sf.data.query 'SELECT Id, Name FROM Account LIMIT 3' # => returns an array containing 3 records
46
-
47
- # generate a Salesforce DX project
48
- sf.project.generate 'MyProject'
41
+ Create a record
42
+ sf.data.create_record :TheCustomObject__c, values: {Name: "John Smith", Age: 33}
49
43
 
50
- == \Object Model support (experimental, since 0.0.4)
51
- === generate Models
52
- require 'sf_cli/sf/model'
53
- require 'sf_cli/sf/model/sf_command_connection'
44
+ Update a record
45
+ sf.data.update_record :Account, record_id: 'xxxxxxx', values: {Name: 'New Account Name'}
46
+ sf.data.update_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}, values: {Phone: 'xxxxx', bar: 2000}
54
47
 
55
- # first, you must prepare the connection
56
- conn = SfCli::Sf::Model::SfCommandConnection.new target_org: your_org, instance_url: your_org_url
48
+ Delete a record
49
+ sf.data.delete_record :Hoge__c, record_id: 'xxxxxxx'
50
+ sf.data.delete_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}
57
51
 
58
- # then set it to Model module
59
- SfCli::Sf::Model.set_connection conn
52
+ Using Bulk API 2.0
53
+ sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv', timeout: 5 # waiting for 5 minutes at maximum
60
54
 
61
- # generates some model classes (for example, Account and Contact)
62
- SfCli::Sf::Model.generate %w[Account Contact]
63
- === apply to sf command
55
+ Run Apex
56
+ sf.apex.run file: 'path/to/file'
57
+ sf.apex.run file: StringIO.new("System.debug('Hello World')")
58
+ == Object Model Support (experimental)
59
+ With sf command:
64
60
  rows = sf.data.query "SELECT Id, Name FROM Contact WHERE Name = 'Akin Kristen'", model_class: Contact
65
-
66
- # the array object contains Contact object instances
67
- rows.size # 1
68
- rows.first # <Contact: @Id="0035j00001RW3xbAAD", @Name="Akin Kristen">
61
+ rows.first # <Contact: @Id="0035j00001RW3xbAAD", @Name="Akin Kristen">
69
62
  rows.first.Name # Akin Kristen
70
-
71
- === using models Independently
72
- ==== initialize and save a record
73
- c = Contact.new(:Name => "John Smith")
74
- c.Name # "John Smith"
75
- c.save
76
-
77
- ==== find and update a record
78
- # find by record ID and update
79
- c2 = Contact.find(c.id)
80
- c2.Name = "Johnny Smith"
81
- c2.save # update
82
-
83
- ==== delete a record
84
- c2 = Contact.find(c.id)
85
- c2.delete
86
-
87
- ==== query and get a record
63
+ Doing the same thing independently:
88
64
  contact = Contact.select(:Id, :Name).where(Name: 'Akin Kristen').take
89
- contact # => #<Contact: @Id="0035j00001RW3xbAAD", @Name="Akin Kristen">
90
65
  contact.Name # Akin Kristen
91
-
92
- # these 2 example are the same meaning
93
- Contact.select(Name).where(Name: 'John Smith', LastModifiedDate: :Yesterday).take
94
- Contact.select(Name).where(Name: 'John Smith').where(LastModifiedDate: :Yesterday).take
95
-
96
- ==== query and get records
97
- contacts = Contact.select(:Id, :Name).where(LastModifiedDate: :Yesterday).all # get all records that is modified yesterday
98
-
99
- ==== child-parent relationship
100
- contact = Contact.select(:Id, :Name, "Account.Name").where(Name: 'Akin Kristen').take
101
- contact # <Contact: @Id="0035j00001RW3xbAAD", @Name="Akin Kristen", @Account= #<Account @Name="Aethna Home Products">>
102
- contact.Account.Name # Aethna Home Products
103
-
104
- ==== parent-children relationship
105
- account = Account.select(:Id, :Name, "(SELECT Name FROM Contacts)").take
106
- account # <Account @Contacts=[#<Contact @Name="Akin Kristen">], @Id="0015j00001dsDuhAAE", @Name="Aethna Home Products">
107
- account.Name # Aethna Home Products
108
- rows.Contacts # [#<Contact @Name="Akin Kristen">]
109
- rows.Contacts.first.Name # Akin Kristen
110
-
111
- ==== get all fields in a record
112
- # just by not using 'select' method
113
- contact = Contact.find(record_id) # <Contact @Id="...", @Name="...", other fields...>
114
-
115
- ==== time keywords such as 'yesterday' or 'LAST_N_DAYS:N' with symbol style
116
- Contact.select(:Name).where(LastModifiedDate: :Yesterday).take # "SELECT Id, Name FROM Contact WHERE LastModifiedDate = Yesterday"
117
- Contact.select(:Name).where(LastModifiedDate: :"LAST_N_DAYS:5").take # "SELECT Id, Name FROM Contact WHERE LastModifiedDate = LAST_N_DAYS:5"
118
-
119
- ==== array for 'IN' keyword
120
- Contact.select(:Name).where(Name: ['Jonny Good', 'John Smith']).all # same as "SELECT Name FROM Contact WHERE Name IN ('Jonny Good', 'John Smith')"
121
-
122
- ==== using partial soql directly
123
- Contact.select("Id, Name").where("LastModifiedDate = LAST_N_DAYS:5").all
124
-
125
- ==== ternary style
126
- Contact.select(:Id, :Name).where(:LastModifiedDate, :>=, :"LAST_N_DAYS:5").all # SELECT Id, Name FROM Contact WHERE LastModifiedDate >= LAST_N_DAYS:5
127
- Account.select(:Id, :Name).where(:Name, :LIKE, "%OIL%").all # SELECT Id, Name FROM Account WHERE Name LIKE '%OIL%'
128
-
129
- ==== get schema
130
- schema = Account.describe
131
- schema.name # Account
132
- schema.field_names # [Id, Name, ....]
133
-
134
- == Documents
135
- The following steps generate *doc* directory, which all documents are generated in.
136
- $ git clone https://github.com/tmkw/sf_cli.git
137
- $ cd sf_cli
138
- $ bundle install
139
- $ bundle exec rake rdoc
140
-
141
- *Or*, you can read the same documents online at {rubygems.org}[https://rubygems.org/gems/sf_cli]
@@ -0,0 +1,36 @@
1
+ require 'sf_cli'
2
+ require 'sf_cli/sf/model'
3
+ require 'sf_cli/sf/model/sf_command_connection'
4
+ require 'stringio'
5
+
6
+ module SfCli
7
+ module Console
8
+ module Commands
9
+ def use(_target_org)
10
+ target_org = _target_org.to_sym == :default ? nil : _target_org
11
+ org_info = sf.org.display target_org: target_org
12
+ conn = SfCli::Sf::Model::SfCommandConnection.new target_org: target_org, instance_url: org_info.instance_url
13
+ SfCli::Sf::Model.set_connection conn
14
+ end
15
+
16
+ def generate(*object_types)
17
+ SfCli::Sf::Model.generate object_types
18
+ end
19
+
20
+ def connection
21
+ SfCli::Sf::Model.connection
22
+ end
23
+
24
+ def target_org
25
+ connection.target_org
26
+ end
27
+
28
+ def apex(apex_code)
29
+ sf.apex.run target_org: target_org, file: StringIO.new(apex_code)
30
+ end
31
+
32
+ alias :gen :generate
33
+ alias :conn :connection
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ require 'sf_cli/console/commands'
2
+
3
+ include SfCli::Console::Commands
4
+
5
+ use ARGV[0]
@@ -0,0 +1,18 @@
1
+ require_relative '../core/base'
2
+ require_relative './run'
3
+
4
+ module SfCli
5
+ module Sf
6
+ # Apex Commands
7
+ #
8
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_apex_commands_unified.htm command reference
9
+ #
10
+ module Apex
11
+ # @private :nodoc: just for developers
12
+ class Core
13
+ include ::SfCli::Sf::Core::Base
14
+ include Run
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,113 @@
1
+ require 'tempfile'
2
+ require 'stringio'
3
+
4
+ module SfCli::Sf::Apex
5
+ module Run
6
+ #
7
+ # Run apex code and returns its result.
8
+ # If you don't specify the script file, it starts interactive mode.
9
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_apex_commands_unified.htm#cli_reference_apex_run_unified CLI reference
10
+ #
11
+ # @param target_org [Symbol,String]
12
+ # an alias of paticular org, or username can be used.
13
+ #
14
+ # @param file [String,StringIO]
15
+ # (1) path to a local file that contains Apex code.
16
+ # (2) StringIO object
17
+ #
18
+ # @return [ApexResult] Apex execution result.
19
+ #
20
+ # @example Execute apex code in a file
21
+ # result = sf.apex.run file: "path/to/apex"
22
+ # result.success # true if the execution succeeds
23
+ # result.logs # execution log
24
+ #
25
+ # @example StringIO is usable instead of file path
26
+ # require 'stringio'
27
+ #
28
+ # pseudo_file = StringIO.new <<~EOS
29
+ # Account acc = [SELECT Id, Name FROM Account Limit 1];
30
+ # System.debug(acc.Name);
31
+ # EOS
32
+ #
33
+ # sf.apex.run target_org: :dev, file: pseudo_file
34
+ #
35
+ # @example Interactive Mode
36
+ # irb(main:) > sf.apex.run target_org: :dev
37
+ #
38
+ # Account acc = [SELECT Id, Name FROM Account LIMIT 1];
39
+ # System.debug(acc.Name);
40
+ # <press Ctrl-D>
41
+ #
42
+ # =>
43
+ # #<SfCli::Sf::Apex::Run::ApexResult:0x00007437b4e13218
44
+ # @column=-1,
45
+ # @compile_problem="",
46
+ # @compiled=true,
47
+ # @exception_message="",
48
+ # @exception_stack_trace="",
49
+ # @line=-1,
50
+ # @logs=
51
+ # ["61.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO",
52
+ # "Execute Anonymous: Account acc = [SELECT Id, Name FROM Account LIMIT 1];",
53
+ # "Execute Anonymous: System.debug(acc.Name);",
54
+ # ....]
55
+ #
56
+ def run(target_org: nil, file: nil)
57
+ return run_interactive(target_org) if file.nil?
58
+ return run_by_io(target_org, file) if file.is_a? StringIO
59
+
60
+ return unless file.is_a? String
61
+
62
+ flags = {:"target-org" => target_org, :"file" => file}
63
+
64
+ json = exec(__method__, flags: flags, redirection: :null_stderr)
65
+ ApexResult.new(json['result'])
66
+ end
67
+
68
+ private
69
+
70
+ def run_by_io(target_org, io)
71
+ file = Tempfile.open(%w[sf apex]){|f| f.write(io.read); f}
72
+
73
+ flags = {:"target-org" => target_org, :"file" => file.path}
74
+ json = exec(:run, flags: flags, redirection: :null_stderr)
75
+ ApexResult.new(json['result'])
76
+ ensure
77
+ file&.close!
78
+ end
79
+
80
+ def run_interactive(target_org)
81
+ file = Tempfile.open(%w[sf apex]) do |f|
82
+ s = $stdin.gets
83
+ while s
84
+ f.puts(s)
85
+ s = $stdin.gets
86
+ end
87
+ f
88
+ end
89
+
90
+ flags = {:"target-org" => target_org, :"file" => file.path}
91
+
92
+ json = exec(:run, flags: flags, redirection: :null_stderr)
93
+ ApexResult.new(json['result'])
94
+ ensure
95
+ file&.close!
96
+ end
97
+
98
+ class ApexResult
99
+ attr_reader :success, :compiled, :compile_problem, :exception_message, :exception_stack_trace, :line, :column, :logs
100
+
101
+ def initialize(attributes)
102
+ @success = attributes['success']
103
+ @compiled = attributes['compiled']
104
+ @compile_problem = attributes['compileProblem']
105
+ @exception_message = attributes['exceptionMessage']
106
+ @exception_stack_trace = attributes['exceptionStackTrace']
107
+ @line = attributes['line']
108
+ @column = attributes['column']
109
+ @logs = attributes['logs'].chomp.split("\n")
110
+ end
111
+ end
112
+ end
113
+ end
@@ -2,6 +2,7 @@ require 'json'
2
2
 
3
3
  module SfCli
4
4
  module Sf
5
+ # @private :nodoc: just for developers
5
6
  module Core
6
7
  module Base
7
8
  attr_reader :varbose
@@ -1,7 +1,6 @@
1
1
  module SfCli
2
2
  module Sf
3
3
  module Data
4
- #
5
4
  # Bulk Job information.
6
5
  #
7
6
  # You can check the job status using the following method:
@@ -9,11 +8,11 @@ module SfCli
9
8
  # - upload_completed?
10
9
  # - in_progress?
11
10
  # - completed?
12
- # ==== example:
11
+ # @example
13
12
  # result = sf.data.delete_resume job_id: jobinfo.id
14
13
  # puts 'yey!' if result.job_info.completed? # the job has completed
15
14
  #
16
- # For more details, see {the guide document}[https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/bulk_api_2_job_states.htm]
15
+ # See Also: {https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/bulk_api_2_job_states.htm the guide document}
17
16
  #
18
17
  JobInfo = Struct.new(
19
18
  :id,
@@ -13,13 +13,12 @@ require_relative './search'
13
13
 
14
14
  module SfCli
15
15
  module Sf
16
+ #
17
+ # Data Command
18
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm command reference
19
+ #
16
20
  module Data
17
- #
18
- # ==== description
19
- # The class representing *sf* *data*
20
- #
21
- # https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm
22
- #
21
+ # @private :nodoc: just for developers
23
22
  class Core
24
23
  include ::SfCli::Sf::Core::Base
25
24
  include Query
@@ -1,19 +1,17 @@
1
1
  module SfCli::Sf::Data
2
2
  module CreateRecord
3
3
  # create a object record.
4
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_create_record_unified command reference
5
+ # @param object_type [Symbol, String] object type(ex. Account)
6
+ # @param values [Hash] field values to be assigned
7
+ # @param target_org [Symbol, String] an alias of paticular org, or username can be used
4
8
  #
5
- # *object_type* --- \Object Type (ex. Account)<br>
9
+ # @return [String] record ID
6
10
  #
7
- # *values* --- field values to be assigned<br>
8
- #
9
- # *target_org* --- an alias of paticular org, or username can be used<br>
10
- #
11
- # ======
11
+ # @example
12
12
  # # create a TheCustomObject record with name and age
13
13
  # sf.data.create_record :TheCustomObject__c, values: {Name: "John Smith", Age: 33}
14
14
  #
15
- # For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_create_record_unified]
16
- #
17
15
  def create_record(object_type, values: {}, target_org: nil)
18
16
  field_values = field_value_pairs(values)
19
17
  flags = {
@@ -2,17 +2,15 @@ require_relative './bulk_result_v2'
2
2
 
3
3
  module SfCli::Sf::Data
4
4
  module DeleteBulk
5
- # delete records using Bulk API 2.0
5
+ # Delete records using Bulk API 2.0
6
+ # @param file [String] path of a CSV file, which is written record IDs to delete
7
+ # @param sobject [Symbol, String] object type (ex. Account)
8
+ # @param timeout [Integer] max minutes to wait for the job complete the task.
9
+ # @param target_org [Symbol, String] an alias of paticular org, or username can be used
6
10
  #
7
- # *file* --- a CSV file, which is written record IDs to delete<br>
11
+ # @return [JobInfo, BulkResultV2] the job result, whose type is changed by situation
8
12
  #
9
- # *sobject* --- \Object Type (ex. Account)<br>
10
- #
11
- # *timeout* --- max minutes to wait for the job complete the task.<br>
12
- #
13
- # *target_org* --- an alias of paticular org, or username can be used<br>
14
- #
15
- # ======
13
+ # @example
16
14
  # # start a delete job
17
15
  # jobinfo = sf.data.delete_bulk sobject: :TestCustomObject__c, file: 'delete.csv' # this returns immediately
18
16
  # jobinfo.id # => "750J4000003g1OaIAI" it's job ID
@@ -23,7 +21,8 @@ module SfCli::Sf::Data
23
21
  # # Or, you can wait for the job completion with one try.
24
22
  # result = sf.data.delete_bulk sobject: :TestCustomObject__c, file: 'delete.csv', timeout: 5 # wait within 5 minutes
25
23
  #
26
- # For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_delete_bulk_unified]
24
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_delete_bulk_unified command reference
25
+ #
27
26
  #
28
27
  def delete_bulk(file:, sobject:, timeout: nil, target_org: nil)
29
28
  flags = {
@@ -1,20 +1,19 @@
1
1
  module SfCli::Sf::Data
2
2
  module DeleteRecord
3
- # delete a object record.
3
+ # Delete a object record.
4
4
  #
5
- # *object_type* --- \Object Type (ex. Account)<br>
5
+ # @param object_type [Symbol, String] Object Type (ex. Account)
6
+ # @param record_id [String] Id of the object
7
+ # @param where [Hash] conditions to identify a record
8
+ # @param target_org [Symbol, String] an alias of paticular org, or username can be used
6
9
  #
7
- # *record_id* --- id of the object<br>
10
+ # @return [String] ID that is deleted.
8
11
  #
9
- # *where* --- hash object that is used to identify a record<br>
10
- #
11
- # *target_org* --- an alias of paticular org, or username can be used<br>
12
- #
13
- # ======
12
+ # @example
14
13
  # sf.data.delete_record :Hoge__c, record_id: 'xxxxxxx'
15
14
  # sf.data.delete_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}
16
15
  #
17
- # For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_delete_record_unified]
16
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_delete_record_unified the command reference
18
17
  #
19
18
  def delete_record(object_type, record_id: nil, where: nil, target_org: nil)
20
19
  where_conditions = field_value_pairs(where)
@@ -2,15 +2,15 @@ require_relative './bulk_result_v2'
2
2
 
3
3
  module SfCli::Sf::Data
4
4
  module DeleteResume
5
- # resume a bulk delete job you previously started with Bulk API 2.0 and return a bulk result object.
5
+ # Resume a bulk delete job you previously started with Bulk API 2.0 and return a bulk result object.
6
6
  #
7
- # *job_id* --- job ID you want to resume<br>
7
+ # @param job_id [String] job ID you want to resume<br>
8
+ # @param timeout [Integer] max minutes to wait for the job complete the task.<br>
9
+ # @param target_org [Symbol, String] an alias of paticular org, or username can be used<br>
8
10
  #
9
- # *timeout* --- max minutes to wait for the job complete the task.<br>
11
+ # @return [JobInfo, BulkResultV2] the job result, whose type is changed by situation
10
12
  #
11
- # *target_org* --- an alias of paticular org, or username can be used<br>
12
- #
13
- # ======
13
+ # @example
14
14
  # # start a delete job
15
15
  # jobinfo = sf.data.delete_bulk sobject: :TestCustomObject__c, file: 'delete.csv' # this returns immediately
16
16
  # jobinfo.id # => "750J4000003g1OaIAI" it's job ID
@@ -22,9 +22,7 @@ module SfCli::Sf::Data
22
22
  #
23
23
  # puts 'yey!' if result.job_info.completed? # the job has completed
24
24
  #
25
- # To know more about a job result, take a look at SfCli::Sf::Data module
26
- #
27
- # For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_delete_resume_unified]
25
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_delete_resume_unified the command reference
28
26
  #
29
27
  def delete_resume(job_id:, timeout: nil, target_org: nil)
30
28
  flags = {
@@ -1,26 +1,24 @@
1
1
  module SfCli::Sf::Data
2
2
  module GetRecord
3
3
 
4
- # get a object record. (eqivalent to *sf* *data* *get* *record*)
4
+ # Get a object record.
5
+ # @param object_type [Symbol,String] object type(ex. Account)
6
+ # @param record_id [String] id of the object
7
+ # @param where [Hash] conditions to identify a record
8
+ # @param target_org [Symbol,String] an alias of paticular org, not default one
9
+ # @param model_class [Class] the object model class
5
10
  #
6
- # *object_type* --- \Object Type (ex. Account)<br>
11
+ # @return [Hash,Class] if proper model class is specified, the return value is the instance of the class. Otherwise, it's a Hash object.
7
12
  #
8
- # *record_id* --- id of the object<br>
9
- #
10
- # *where* --- hash object that is used to identify a record<br>
11
- #
12
- # *target_org* --- an alias of paticular org, not default one<br>
13
- #
14
- # *model_class* --- the object model class<br>
15
- #
16
- # ======
13
+ # @example
17
14
  # sf.data.get_record :Account, record_id: 'xxxxxxx'
18
15
  # sf.data.get_record :Account, where: {Name: 'Jonny B.Good', Country: 'USA'}
19
16
  #
20
17
  # CustomObject = Struct.new(:Id, :Name)
21
- # sf.data.get_record :TheCustomObject__c, record_id: 'xxxxx', model_class: CustomObject # returns a CustomObject instance
18
+ # obj = sf.data.get_record :TheCustomObject__c, record_id: 'xxxxx', model_class: CustomObject # returns a CustomObject instance
19
+ # obj.Name # Name field of the record
22
20
  #
23
- # For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_get_record_unified]
21
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_get_record_unified command reference
24
22
  #
25
23
  def get_record(object_type, record_id: nil, where: nil, target_org: nil, model_class: nil)
26
24
  where_conditions = field_value_pairs(where)
@@ -1,6 +1,7 @@
1
1
  module SfCli
2
2
  module Sf
3
3
  module Data
4
+ # @private
4
5
  module HelperMethods
5
6
  def prepare_record(hash) # :doc:
6
7
  hash.delete 'attributes'