Class: Files::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/schedule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ Schedule

Returns a new instance of Schedule.



7
8
9
10
# File 'lib/files.com/models/schedule.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/schedule.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/schedule.rb', line 5

def options
  @options
end

Class Method Details

.all(params = {}, options = {}) ⇒ Object



146
147
148
# File 'lib/files.com/models/schedule.rb', line 146

def self.all(params = {}, options = {})
  list(params, options)
end

.create(params = {}, options = {}) ⇒ Object

Parameters:

name (required) - string - Schedule name.
schedule_days_of_week (required) - array(int64) - 0-based weekdays used by the Schedule. 0 is Sunday.
schedule_times_of_day (required) - array(string) - Times of day in HH:MM format (24-hour).
schedule_time_zone - string - Time zone for scheduled times. If not set, times are interpreted as UTC.
holiday_region - string - Optional holiday region on which linked resources do not run.


172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/files.com/models/schedule.rb', line 172

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: schedule_days_of_week must be an Array") if params[:schedule_days_of_week] and !params[:schedule_days_of_week].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: schedule_times_of_day must be an Array") if params[:schedule_times_of_day] and !params[:schedule_times_of_day].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: schedule_time_zone must be an String") if params[:schedule_time_zone] and !params[:schedule_time_zone].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: holiday_region must be an String") if params[:holiday_region] and !params[:holiday_region].is_a?(String)
  raise MissingParameterError.new("Parameter missing: name") unless params[:name]
  raise MissingParameterError.new("Parameter missing: schedule_days_of_week") unless params[:schedule_days_of_week]
  raise MissingParameterError.new("Parameter missing: schedule_times_of_day") unless params[:schedule_times_of_day]

  response, options = Api.send_request("/schedules", :post, params, options)
  Schedule.new(response.data, options)
end

.delete(id, params = {}, options = {}) ⇒ Object



207
208
209
210
211
212
213
214
215
# File 'lib/files.com/models/schedule.rb', line 207

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/schedules/#{params[:id]}", :delete, params, options)
  nil
end

.destroy(id, params = {}, options = {}) ⇒ Object



217
218
219
220
# File 'lib/files.com/models/schedule.rb', line 217

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
  nil
end

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - int64 - Schedule ID.


152
153
154
155
156
157
158
159
160
# File 'lib/files.com/models/schedule.rb', line 152

def self.find(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  response, options = Api.send_request("/schedules/#{params[:id]}", :get, params, options)
  Schedule.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



162
163
164
# File 'lib/files.com/models/schedule.rb', line 162

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

cursor - string - Used for pagination.  When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`.  Send one of those cursor value here to resume an existing list from the next available record.  Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page.  (Max: 10000, 1,000 or less is recommended).
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `name`.


136
137
138
139
140
141
142
143
144
# File 'lib/files.com/models/schedule.rb', line 136

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash)

  List.new(Schedule, params) do
    Api.send_request("/schedules", :get, params, options)
  end
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

name - string - Schedule name.
schedule_days_of_week - array(int64) - 0-based weekdays used by the Schedule. 0 is Sunday.
schedule_times_of_day - array(string) - Times of day in HH:MM format (24-hour).
schedule_time_zone - string - Time zone for scheduled times. If not set, times are interpreted as UTC.
holiday_region - string - Optional holiday region on which linked resources do not run.


192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/files.com/models/schedule.rb', line 192

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: schedule_days_of_week must be an Array") if params[:schedule_days_of_week] and !params[:schedule_days_of_week].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: schedule_times_of_day must be an Array") if params[:schedule_times_of_day] and !params[:schedule_times_of_day].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: schedule_time_zone must be an String") if params[:schedule_time_zone] and !params[:schedule_time_zone].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: holiday_region must be an String") if params[:holiday_region] and !params[:holiday_region].is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  response, options = Api.send_request("/schedules/#{params[:id]}", :patch, params, options)
  Schedule.new(response.data, options)
end

Instance Method Details

#created_atObject

date-time - Creation time.



76
77
78
# File 'lib/files.com/models/schedule.rb', line 76

def created_at
  @attributes[:created_at]
end

#delete(params = {}) ⇒ Object



106
107
108
109
110
111
112
113
114
# File 'lib/files.com/models/schedule.rb', line 106

def delete(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/schedules/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



116
117
118
119
# File 'lib/files.com/models/schedule.rb', line 116

def destroy(params = {})
  delete(params)
  nil
end

#holiday_regionObject

string - Optional holiday region on which linked resources do not run.



58
59
60
# File 'lib/files.com/models/schedule.rb', line 58

def holiday_region
  @attributes[:holiday_region]
end

#holiday_region=(value) ⇒ Object



62
63
64
# File 'lib/files.com/models/schedule.rb', line 62

def holiday_region=(value)
  @attributes[:holiday_region] = value
end

#human_readable_scheduleObject

string - Human-readable Schedule description.



67
68
69
# File 'lib/files.com/models/schedule.rb', line 67

def human_readable_schedule
  @attributes[:human_readable_schedule]
end

#human_readable_schedule=(value) ⇒ Object



71
72
73
# File 'lib/files.com/models/schedule.rb', line 71

def human_readable_schedule=(value)
  @attributes[:human_readable_schedule] = value
end

#idObject

int64 - Schedule ID.



13
14
15
# File 'lib/files.com/models/schedule.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/schedule.rb', line 17

def id=(value)
  @attributes[:id] = value
end

#nameObject

string - Schedule name.



22
23
24
# File 'lib/files.com/models/schedule.rb', line 22

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/schedule.rb', line 26

def name=(value)
  @attributes[:name] = value
end

#saveObject



121
122
123
124
125
126
127
128
129
130
# File 'lib/files.com/models/schedule.rb', line 121

def save
  if @attributes[:id]
    new_obj = update(@attributes)
  else
    new_obj = Schedule.create(@attributes, @options)
  end

  @attributes = new_obj.attributes
  true
end

#schedule_days_of_weekObject

array(int64) - 0-based weekdays used by the Schedule. 0 is Sunday.



31
32
33
# File 'lib/files.com/models/schedule.rb', line 31

def schedule_days_of_week
  @attributes[:schedule_days_of_week]
end

#schedule_days_of_week=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/schedule.rb', line 35

def schedule_days_of_week=(value)
  @attributes[:schedule_days_of_week] = value
end

#schedule_time_zoneObject

string - Time zone for scheduled times. If not set, times are interpreted as UTC.



49
50
51
# File 'lib/files.com/models/schedule.rb', line 49

def schedule_time_zone
  @attributes[:schedule_time_zone]
end

#schedule_time_zone=(value) ⇒ Object



53
54
55
# File 'lib/files.com/models/schedule.rb', line 53

def schedule_time_zone=(value)
  @attributes[:schedule_time_zone] = value
end

#schedule_times_of_dayObject

array(string) - Times of day in HH:MM format (24-hour).



40
41
42
# File 'lib/files.com/models/schedule.rb', line 40

def schedule_times_of_day
  @attributes[:schedule_times_of_day]
end

#schedule_times_of_day=(value) ⇒ Object



44
45
46
# File 'lib/files.com/models/schedule.rb', line 44

def schedule_times_of_day=(value)
  @attributes[:schedule_times_of_day] = value
end

#update(params = {}) ⇒ Object

Parameters:

name - string - Schedule name.
schedule_days_of_week - array(int64) - 0-based weekdays used by the Schedule. 0 is Sunday.
schedule_times_of_day - array(string) - Times of day in HH:MM format (24-hour).
schedule_time_zone - string - Time zone for scheduled times. If not set, times are interpreted as UTC.
holiday_region - string - Optional holiday region on which linked resources do not run.


91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/files.com/models/schedule.rb', line 91

def update(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: schedule_days_of_week must be an Array") if params[:schedule_days_of_week] and !params[:schedule_days_of_week].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: schedule_times_of_day must be an Array") if params[:schedule_times_of_day] and !params[:schedule_times_of_day].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: schedule_time_zone must be an String") if params[:schedule_time_zone] and !params[:schedule_time_zone].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: holiday_region must be an String") if params[:holiday_region] and !params[:holiday_region].is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/schedules/#{@attributes[:id]}", :patch, params, @options)
end

#updated_atObject

date-time - Last update time.



81
82
83
# File 'lib/files.com/models/schedule.rb', line 81

def updated_at
  @attributes[:updated_at]
end