Class: Fastly::HistoricalApi

Inherits:
Object
  • Object
show all
Defined in:
lib/fastly/api/historical_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ HistoricalApi

Returns a new instance of HistoricalApi.



17
18
19
# File 'lib/fastly/api/historical_api.rb', line 17

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



15
16
17
# File 'lib/fastly/api/historical_api.rb', line 15

def api_client
  @api_client
end

Instance Method Details

#get_hist_stats(opts = {}) ⇒ HistoricalStatsByServiceResponse

Get historical stats Fetches historical stats for each of your Fastly services and groups the results by service ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `southamerica_std` - South America.

Returns:



27
28
29
30
# File 'lib/fastly/api/historical_api.rb', line 27

def get_hist_stats(opts = {})
  data, _status_code, _headers = get_hist_stats_with_http_info(opts)
  data
end

#get_hist_stats_aggregated(opts = {}) ⇒ HistoricalStatsAggregatedResponse

Get aggregated historical stats Fetches historical stats information aggregated across all of your Fastly services.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `southamerica_std` - South America.

Returns:



103
104
105
106
# File 'lib/fastly/api/historical_api.rb', line 103

def get_hist_stats_aggregated(opts = {})
  data, _status_code, _headers = get_hist_stats_aggregated_with_http_info(opts)
  data
end

#get_hist_stats_aggregated_with_http_info(opts = {}) ⇒ Array<(HistoricalStatsAggregatedResponse, Integer, Hash)>

Get aggregated historical stats Fetches historical stats information aggregated across all of your Fastly services.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * &#x60;hour&#x60; - Group data by hour. * &#x60;minute&#x60; - Group data by minute. * &#x60;day&#x60; - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * &#x60;usa&#x60; - North America. * &#x60;europe&#x60; - Europe. * &#x60;anzac&#x60; - Australia and New Zealand. * &#x60;asia&#x60; - Asia. * &#x60;asia_india&#x60; - India. * &#x60;asia_southkorea&#x60; - South Korea. * &#x60;africa_std&#x60; - Africa. * &#x60;southamerica_std&#x60; - South America.

Returns:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/fastly/api/historical_api.rb', line 115

def get_hist_stats_aggregated_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: HistoricalApi.get_hist_stats_aggregated ...'
  end
  # unbox the parameters from the hash
  allowable_values = ["hour", "minute", "day"]
  if @api_client.config.client_side_validation && opts[:'by'] && !allowable_values.include?(opts[:'by'])
    fail ArgumentError, "invalid value for \"by\", must be one of #{allowable_values}"
  end
  allowable_values = ["usa", "europe", "asia", "asia_india", "asia_southkorea", "africa_std", "southamerica_std"]
  if @api_client.config.client_side_validation && opts[:'region'] && !allowable_values.include?(opts[:'region'])
    fail ArgumentError, "invalid value for \"region\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/stats/aggregate'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  query_params[:'by'] = opts[:'by'] if !opts[:'by'].nil?
  query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'HistoricalStatsAggregatedResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"HistoricalApi.get_hist_stats_aggregated",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: HistoricalApi#get_hist_stats_aggregated\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_hist_stats_field(opts = {}) ⇒ HistoricalStatsByServiceResponse

Get historical stats for a single field Fetches the specified field from the historical stats for each of your services and groups the results by service ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :field (String)

    Name of the stats field. (required)

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * &#x60;hour&#x60; - Group data by hour. * &#x60;minute&#x60; - Group data by minute. * &#x60;day&#x60; - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * &#x60;usa&#x60; - North America. * &#x60;europe&#x60; - Europe. * &#x60;anzac&#x60; - Australia and New Zealand. * &#x60;asia&#x60; - Asia. * &#x60;asia_india&#x60; - India. * &#x60;asia_southkorea&#x60; - South Korea. * &#x60;africa_std&#x60; - Africa. * &#x60;southamerica_std&#x60; - South America.

Returns:



180
181
182
183
# File 'lib/fastly/api/historical_api.rb', line 180

def get_hist_stats_field(opts = {})
  data, _status_code, _headers = get_hist_stats_field_with_http_info(opts)
  data
end

#get_hist_stats_field_with_http_info(opts = {}) ⇒ Array<(HistoricalStatsByServiceResponse, Integer, Hash)>

Get historical stats for a single field Fetches the specified field from the historical stats for each of your services and groups the results by service ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :field (String)

    Name of the stats field. (required)

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * &#x60;hour&#x60; - Group data by hour. * &#x60;minute&#x60; - Group data by minute. * &#x60;day&#x60; - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * &#x60;usa&#x60; - North America. * &#x60;europe&#x60; - Europe. * &#x60;anzac&#x60; - Australia and New Zealand. * &#x60;asia&#x60; - Asia. * &#x60;asia_india&#x60; - India. * &#x60;asia_southkorea&#x60; - South Korea. * &#x60;africa_std&#x60; - Africa. * &#x60;southamerica_std&#x60; - South America.

Returns:



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/fastly/api/historical_api.rb', line 193

def get_hist_stats_field_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: HistoricalApi.get_hist_stats_field ...'
  end
  # unbox the parameters from the hash
  field = opts[:'field']
  # verify the required parameter 'field' is set
  if @api_client.config.client_side_validation && field.nil?
    fail ArgumentError, "Missing the required parameter 'field' when calling HistoricalApi.get_hist_stats_field"
  end
  allowable_values = ["hour", "minute", "day"]
  if @api_client.config.client_side_validation && opts[:'by'] && !allowable_values.include?(opts[:'by'])
    fail ArgumentError, "invalid value for \"by\", must be one of #{allowable_values}"
  end
  allowable_values = ["usa", "europe", "asia", "asia_india", "asia_southkorea", "africa_std", "southamerica_std"]
  if @api_client.config.client_side_validation && opts[:'region'] && !allowable_values.include?(opts[:'region'])
    fail ArgumentError, "invalid value for \"region\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/stats/field/{field}'.sub('{' + 'field' + '}', CGI.escape(field.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  query_params[:'by'] = opts[:'by'] if !opts[:'by'].nil?
  query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'HistoricalStatsByServiceResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"HistoricalApi.get_hist_stats_field",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: HistoricalApi#get_hist_stats_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_hist_stats_service(opts = {}) ⇒ HistoricalStatsAggregatedResponse

Get historical stats for a single service Fetches historical stats for a given service.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * &#x60;hour&#x60; - Group data by hour. * &#x60;minute&#x60; - Group data by minute. * &#x60;day&#x60; - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * &#x60;usa&#x60; - North America. * &#x60;europe&#x60; - Europe. * &#x60;anzac&#x60; - Australia and New Zealand. * &#x60;asia&#x60; - Asia. * &#x60;asia_india&#x60; - India. * &#x60;asia_southkorea&#x60; - South Korea. * &#x60;africa_std&#x60; - Africa. * &#x60;southamerica_std&#x60; - South America.

Returns:



263
264
265
266
# File 'lib/fastly/api/historical_api.rb', line 263

def get_hist_stats_service(opts = {})
  data, _status_code, _headers = get_hist_stats_service_with_http_info(opts)
  data
end

#get_hist_stats_service_field(opts = {}) ⇒ HistoricalStatsAggregatedResponse

Get historical stats for a single service/field combination Fetches the specified field from the historical stats for a given service.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :field (String)

    Name of the stats field. (required)

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * &#x60;hour&#x60; - Group data by hour. * &#x60;minute&#x60; - Group data by minute. * &#x60;day&#x60; - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * &#x60;usa&#x60; - North America. * &#x60;europe&#x60; - Europe. * &#x60;anzac&#x60; - Australia and New Zealand. * &#x60;asia&#x60; - Asia. * &#x60;asia_india&#x60; - India. * &#x60;asia_southkorea&#x60; - South Korea. * &#x60;africa_std&#x60; - Africa. * &#x60;southamerica_std&#x60; - South America.

Returns:



347
348
349
350
# File 'lib/fastly/api/historical_api.rb', line 347

def get_hist_stats_service_field(opts = {})
  data, _status_code, _headers = get_hist_stats_service_field_with_http_info(opts)
  data
end

#get_hist_stats_service_field_with_http_info(opts = {}) ⇒ Array<(HistoricalStatsAggregatedResponse, Integer, Hash)>

Get historical stats for a single service/field combination Fetches the specified field from the historical stats for a given service.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :field (String)

    Name of the stats field. (required)

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * &#x60;hour&#x60; - Group data by hour. * &#x60;minute&#x60; - Group data by minute. * &#x60;day&#x60; - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * &#x60;usa&#x60; - North America. * &#x60;europe&#x60; - Europe. * &#x60;anzac&#x60; - Australia and New Zealand. * &#x60;asia&#x60; - Asia. * &#x60;asia_india&#x60; - India. * &#x60;asia_southkorea&#x60; - South Korea. * &#x60;africa_std&#x60; - Africa. * &#x60;southamerica_std&#x60; - South America.

Returns:



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/fastly/api/historical_api.rb', line 361

def get_hist_stats_service_field_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: HistoricalApi.get_hist_stats_service_field ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  field = opts[:'field']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling HistoricalApi.get_hist_stats_service_field"
  end
  # verify the required parameter 'field' is set
  if @api_client.config.client_side_validation && field.nil?
    fail ArgumentError, "Missing the required parameter 'field' when calling HistoricalApi.get_hist_stats_service_field"
  end
  allowable_values = ["hour", "minute", "day"]
  if @api_client.config.client_side_validation && opts[:'by'] && !allowable_values.include?(opts[:'by'])
    fail ArgumentError, "invalid value for \"by\", must be one of #{allowable_values}"
  end
  allowable_values = ["usa", "europe", "asia", "asia_india", "asia_southkorea", "africa_std", "southamerica_std"]
  if @api_client.config.client_side_validation && opts[:'region'] && !allowable_values.include?(opts[:'region'])
    fail ArgumentError, "invalid value for \"region\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/stats/service/{service_id}/field/{field}'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s)).sub('{' + 'field' + '}', CGI.escape(field.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  query_params[:'by'] = opts[:'by'] if !opts[:'by'].nil?
  query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'HistoricalStatsAggregatedResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"HistoricalApi.get_hist_stats_service_field",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: HistoricalApi#get_hist_stats_service_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_hist_stats_service_with_http_info(opts = {}) ⇒ Array<(HistoricalStatsAggregatedResponse, Integer, Hash)>

Get historical stats for a single service Fetches historical stats for a given service.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * &#x60;hour&#x60; - Group data by hour. * &#x60;minute&#x60; - Group data by minute. * &#x60;day&#x60; - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * &#x60;usa&#x60; - North America. * &#x60;europe&#x60; - Europe. * &#x60;anzac&#x60; - Australia and New Zealand. * &#x60;asia&#x60; - Asia. * &#x60;asia_india&#x60; - India. * &#x60;asia_southkorea&#x60; - South Korea. * &#x60;africa_std&#x60; - Africa. * &#x60;southamerica_std&#x60; - South America.

Returns:



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/fastly/api/historical_api.rb', line 276

def get_hist_stats_service_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: HistoricalApi.get_hist_stats_service ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling HistoricalApi.get_hist_stats_service"
  end
  allowable_values = ["hour", "minute", "day"]
  if @api_client.config.client_side_validation && opts[:'by'] && !allowable_values.include?(opts[:'by'])
    fail ArgumentError, "invalid value for \"by\", must be one of #{allowable_values}"
  end
  allowable_values = ["usa", "europe", "asia", "asia_india", "asia_southkorea", "africa_std", "southamerica_std"]
  if @api_client.config.client_side_validation && opts[:'region'] && !allowable_values.include?(opts[:'region'])
    fail ArgumentError, "invalid value for \"region\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/stats/service/{service_id}'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  query_params[:'by'] = opts[:'by'] if !opts[:'by'].nil?
  query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'HistoricalStatsAggregatedResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"HistoricalApi.get_hist_stats_service",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: HistoricalApi#get_hist_stats_service\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_hist_stats_with_http_info(opts = {}) ⇒ Array<(HistoricalStatsByServiceResponse, Integer, Hash)>

Get historical stats Fetches historical stats for each of your Fastly services and groups the results by service ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

  • :by (String)

    Duration of sample windows. One of: * &#x60;hour&#x60; - Group data by hour. * &#x60;minute&#x60; - Group data by minute. * &#x60;day&#x60; - Group data by day. (default to ‘day’)

  • :region (String)

    Limit query to a specific geographic region. One of: * &#x60;usa&#x60; - North America. * &#x60;europe&#x60; - Europe. * &#x60;anzac&#x60; - Australia and New Zealand. * &#x60;asia&#x60; - Asia. * &#x60;asia_india&#x60; - India. * &#x60;asia_southkorea&#x60; - South Korea. * &#x60;africa_std&#x60; - Africa. * &#x60;southamerica_std&#x60; - South America.

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
# File 'lib/fastly/api/historical_api.rb', line 39

def get_hist_stats_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: HistoricalApi.get_hist_stats ...'
  end
  # unbox the parameters from the hash
  allowable_values = ["hour", "minute", "day"]
  if @api_client.config.client_side_validation && opts[:'by'] && !allowable_values.include?(opts[:'by'])
    fail ArgumentError, "invalid value for \"by\", must be one of #{allowable_values}"
  end
  allowable_values = ["usa", "europe", "asia", "asia_india", "asia_southkorea", "africa_std", "southamerica_std"]
  if @api_client.config.client_side_validation && opts[:'region'] && !allowable_values.include?(opts[:'region'])
    fail ArgumentError, "invalid value for \"region\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/stats'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  query_params[:'by'] = opts[:'by'] if !opts[:'by'].nil?
  query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'HistoricalStatsByServiceResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"HistoricalApi.get_hist_stats",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: HistoricalApi#get_hist_stats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_regions(opts = {}) ⇒ HistoricalRegionsResponse

Get region codes Fetches the list of codes for regions that are covered by the Fastly CDN service.



431
432
433
434
# File 'lib/fastly/api/historical_api.rb', line 431

def get_regions(opts = {})
  data, _status_code, _headers = get_regions_with_http_info(opts)
  data
end

#get_regions_with_http_info(opts = {}) ⇒ Array<(HistoricalRegionsResponse, Integer, Hash)>

Get region codes Fetches the list of codes for regions that are covered by the Fastly CDN service.

Returns:

  • (Array<(HistoricalRegionsResponse, Integer, Hash)>)

    HistoricalRegionsResponse data, response status code and response headers



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/fastly/api/historical_api.rb', line 439

def get_regions_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: HistoricalApi.get_regions ...'
  end
  # unbox the parameters from the hash
  # resource path
  local_var_path = '/stats/regions'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'HistoricalRegionsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"HistoricalApi.get_regions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: HistoricalApi#get_regions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_usage(opts = {}) ⇒ HistoricalUsageAggregatedResponse

Get usage statistics Returns usage information aggregated across all Fastly services and grouped by region. To aggregate across all Fastly services by time period, see [‘/stats/aggregate`](#get-hist-stats-aggregated).

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

Returns:



489
490
491
492
# File 'lib/fastly/api/historical_api.rb', line 489

def get_usage(opts = {})
  data, _status_code, _headers = get_usage_with_http_info(opts)
  data
end

#get_usage_month(opts = {}) ⇒ HistoricalUsageMonthResponse

Get month-to-date usage statistics Returns month-to-date usage details for a given month and year. Usage details are aggregated by service and across all Fastly services, and then grouped by region. This endpoint does not use the ‘from` or `to` fields for selecting the date for which data is requested. Instead, it uses `month` and `year` integer fields. Both fields are optional and default to the current month and year respectively. When set, an optional `billable_units` field will convert bandwidth to GB and divide requests by 10,000.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :year (String)

    4-digit year.

  • :month (String)

    2-digit month.

  • :billable_units (Boolean)

    If &#x60;true&#x60;, return results as billable units.

Returns:



552
553
554
555
# File 'lib/fastly/api/historical_api.rb', line 552

def get_usage_month(opts = {})
  data, _status_code, _headers = get_usage_month_with_http_info(opts)
  data
end

#get_usage_month_with_http_info(opts = {}) ⇒ Array<(HistoricalUsageMonthResponse, Integer, Hash)>

Get month-to-date usage statistics Returns month-to-date usage details for a given month and year. Usage details are aggregated by service and across all Fastly services, and then grouped by region. This endpoint does not use the &#x60;from&#x60; or &#x60;to&#x60; fields for selecting the date for which data is requested. Instead, it uses &#x60;month&#x60; and &#x60;year&#x60; integer fields. Both fields are optional and default to the current month and year respectively. When set, an optional &#x60;billable_units&#x60; field will convert bandwidth to GB and divide requests by 10,000.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :year (String)

    4-digit year.

  • :month (String)

    2-digit month.

  • :billable_units (Boolean)

    If &#x60;true&#x60;, return results as billable units.

Returns:



563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
# File 'lib/fastly/api/historical_api.rb', line 563

def get_usage_month_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: HistoricalApi.get_usage_month ...'
  end
  # unbox the parameters from the hash
  # resource path
  local_var_path = '/stats/usage_by_month'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'year'] = opts[:'year'] if !opts[:'year'].nil?
  query_params[:'month'] = opts[:'month'] if !opts[:'month'].nil?
  query_params[:'billable_units'] = opts[:'billable_units'] if !opts[:'billable_units'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'HistoricalUsageMonthResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"HistoricalApi.get_usage_month",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: HistoricalApi#get_usage_month\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_usage_service(opts = {}) ⇒ HistoricalUsageServiceResponse

Get usage statistics per service Returns usage information aggregated by service and grouped by service and region. For service stats by time period, see [‘/stats`](#get-hist-stats) and [`/stats/field/:field`](#get-hist-stats-field).

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

Returns:



616
617
618
619
# File 'lib/fastly/api/historical_api.rb', line 616

def get_usage_service(opts = {})
  data, _status_code, _headers = get_usage_service_with_http_info(opts)
  data
end

#get_usage_service_with_http_info(opts = {}) ⇒ Array<(HistoricalUsageServiceResponse, Integer, Hash)>

Get usage statistics per service Returns usage information aggregated by service and grouped by service and region. For service stats by time period, see [&#x60;/stats&#x60;](#get-hist-stats) and [&#x60;/stats/field/:field&#x60;](#get-hist-stats-field).

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

Returns:



626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
# File 'lib/fastly/api/historical_api.rb', line 626

def get_usage_service_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: HistoricalApi.get_usage_service ...'
  end
  # unbox the parameters from the hash
  # resource path
  local_var_path = '/stats/usage_by_service'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'HistoricalUsageServiceResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"HistoricalApi.get_usage_service",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: HistoricalApi#get_usage_service\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_usage_with_http_info(opts = {}) ⇒ Array<(HistoricalUsageAggregatedResponse, Integer, Hash)>

Get usage statistics Returns usage information aggregated across all Fastly services and grouped by region. To aggregate across all Fastly services by time period, see [&#x60;/stats/aggregate&#x60;](#get-hist-stats-aggregated).

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :from (String)

    Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](github.com/mojombo/chronic), such as &#39;yesterday&#39;, or &#39;two weeks ago&#39;. Default varies based on the value of &#x60;by&#x60;.

  • :to (String)

    Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as &#x60;from&#x60;. (default to ‘now’)

Returns:



499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/fastly/api/historical_api.rb', line 499

def get_usage_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: HistoricalApi.get_usage ...'
  end
  # unbox the parameters from the hash
  # resource path
  local_var_path = '/stats/usage'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'HistoricalUsageAggregatedResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"HistoricalApi.get_usage",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: HistoricalApi#get_usage\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end