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. * `mexico` - Mexico. * `southamerica_std` - South America.

  • :datacenter (String)

    Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](www.fastly.com/documentation/reference/api/utils/pops/).

  • :services (String)

    Limit the query to only the specified, comma-separated list of services.

Returns:



29
30
31
32
# File 'lib/fastly/api/historical_api.rb', line 29

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. * `mexico` - Mexico. * `southamerica_std` - South America.

Returns:



109
110
111
112
# File 'lib/fastly/api/historical_api.rb', line 109

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;mexico&#x60; - Mexico. * &#x60;southamerica_std&#x60; - South America.

Returns:



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
171
172
173
174
175
176
# File 'lib/fastly/api/historical_api.rb', line 121

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", "mexico", "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;mexico&#x60; - Mexico. * &#x60;southamerica_std&#x60; - South America.

  • :datacenter (String)

    Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](www.fastly.com/documentation/reference/api/utils/pops/).

Returns:



187
188
189
190
# File 'lib/fastly/api/historical_api.rb', line 187

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;mexico&#x60; - Mexico. * &#x60;southamerica_std&#x60; - South America.

  • :datacenter (String)

    Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](www.fastly.com/documentation/reference/api/utils/pops/).

Returns:



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
254
255
256
257
258
259
260
261
262
# File 'lib/fastly/api/historical_api.rb', line 201

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", "mexico", "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?
  query_params[:'datacenter'] = opts[:'datacenter'] if !opts[:'datacenter'].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;mexico&#x60; - Mexico. * &#x60;southamerica_std&#x60; - South America.

  • :datacenter (String)

    Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](www.fastly.com/documentation/reference/api/utils/pops/).

Returns:



273
274
275
276
# File 'lib/fastly/api/historical_api.rb', line 273

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;mexico&#x60; - Mexico. * &#x60;southamerica_std&#x60; - South America.

  • :datacenter (String)

    Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](www.fastly.com/documentation/reference/api/utils/pops/).

Returns:



360
361
362
363
# File 'lib/fastly/api/historical_api.rb', line 360

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;mexico&#x60; - Mexico. * &#x60;southamerica_std&#x60; - South America.

  • :datacenter (String)

    Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](www.fastly.com/documentation/reference/api/utils/pops/).

Returns:



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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/fastly/api/historical_api.rb', line 375

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", "mexico", "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?
  query_params[:'datacenter'] = opts[:'datacenter'] if !opts[:'datacenter'].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;mexico&#x60; - Mexico. * &#x60;southamerica_std&#x60; - South America.

  • :datacenter (String)

    Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](www.fastly.com/documentation/reference/api/utils/pops/).

Returns:



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
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/fastly/api/historical_api.rb', line 287

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", "mexico", "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?
  query_params[:'datacenter'] = opts[:'datacenter'] if !opts[:'datacenter'].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;mexico&#x60; - Mexico. * &#x60;southamerica_std&#x60; - South America.

  • :datacenter (String)

    Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](www.fastly.com/documentation/reference/api/utils/pops/).

  • :services (String)

    Limit the query to only the specified, comma-separated list of services.

Returns:



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
95
96
97
98
99
100
# File 'lib/fastly/api/historical_api.rb', line 43

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", "mexico", "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?
  query_params[:'datacenter'] = opts[:'datacenter'] if !opts[:'datacenter'].nil?
  query_params[:'services'] = opts[:'services'] if !opts[:'services'].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.



446
447
448
449
# File 'lib/fastly/api/historical_api.rb', line 446

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



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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/fastly/api/historical_api.rb', line 454

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:



504
505
506
507
# File 'lib/fastly/api/historical_api.rb', line 504

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:



567
568
569
570
# File 'lib/fastly/api/historical_api.rb', line 567

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:



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
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
# File 'lib/fastly/api/historical_api.rb', line 578

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:



631
632
633
634
# File 'lib/fastly/api/historical_api.rb', line 631

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:



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
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# File 'lib/fastly/api/historical_api.rb', line 641

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:



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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/fastly/api/historical_api.rb', line 514

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