Method: GoodData::Schedule.create
- Defined in:
- lib/gooddata/models/schedule.rb
.create(process_id, trigger, executable, options = {}) ⇒ GoodData::Schedule
Creates new schedules from parameters passed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/gooddata/models/schedule.rb', line 64 def create(process_id, trigger, executable, = {}) c, project = GoodData.get_client_and_project() fail 'Process ID has to be provided' if process_id.blank? process = Process[process_id, project: project, client: c] is_dataload_process = process.type == :dataload if is_dataload_process dataload_datasets = [:dataload_datasets] || ['GDC_DATALOAD_DATASETS'] dataload_datasets = '[]' unless dataload_datasets de_synchronize_all = [:de_synchronize_all] || ['GDC_DE_SYNCHRONIZE_ALL'] else lcm_component = process.type == :lcm add_component = process.add_v2_component? executable_missing = !lcm_component && !add_component && executable.blank? fail 'Executable has to be provided' if executable_missing end schedule = c.create(GoodData::Schedule, GoodData::Helpers.stringify_keys(GoodData::Helpers.deep_dup(SCHEDULE_TEMPLATE)), client: c, project: project) params = { 'PROCESS_ID' => process_id } if is_dataload_process params['GDC_DATALOAD_DATASETS'] = dataload_datasets params['GDC_DE_SYNCHRONIZE_ALL'] = de_synchronize_all if de_synchronize_all else params['EXECUTABLE'] = executable end default_opts = { :type => 'MSETL', :timezone => 'UTC', :state => 'ENABLED', :params => params, # :reschedule => nil } schedule.name = [:name] schedule.set_trigger(trigger) schedule.trigger_execution_status = [:trigger_execution_status] schedule.params = default_opts[:params].merge([:params] || {}) schedule.hidden_params = [:hidden_params] || {} schedule.timezone = [:timezone] || default_opts[:timezone] schedule.state = [:state] || default_opts[:state] schedule.schedule_type = [:type] || default_opts[:type] schedule.reschedule = [:reschedule] if [:reschedule] schedule end |