Class: SFRest::Usage

Inherits:
Object
  • Object
show all
Defined in:
lib/sfrest/usage.rb

Overview

Get all the audit devents.

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Usage

Returns a new instance of Usage.

Parameters:



7
8
9
# File 'lib/sfrest/usage.rb', line 7

def initialize(conn)
  @conn = conn
end

Instance Method Details

#monthly(stack_id = 1, datum = {}) ⇒ Hash

Gets the montly usage data.

Parameters:

  • stack_id (Integer) (defaults to: 1)

    The stack of sites of interest

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

    Optional filter parameters

    ‘start_from’ => “YYYY-MM”, # String ‘sort_order’ => “acs|desc”, # String ‘limit’ => Integer, # Number of months to list (max 120) ‘page’ => Integer # Page number to show

Returns:

  • (Hash)

    The dynamic request data.

    { ‘count’ => Integer,

    'time' => String date,
    'most_recent_data' => 'YYYY-MM-DD',
    'dynamic_requests' => {
    '2016-10' => {
      'date' => '2016-10',
       'stack_id' => 1,
       'total_dynamic_requests'=> 106,
       '2xx_dynamic_requests'=> 100,
       '3xx_dynamic_requests'=> 3,
       '4xx_dynamic_requests'=> 2,
       '5xx_dynamic_requests'=> 1,
       'total_runtime'=> 101.4,
       '2xx_runtime'=> 100,
       '3xx_runtime'=> 0.9,
       '4xx_runtime'=> 0.4,
       '5xx_runtime'=> 0.1 }
     }
    


40
41
42
43
44
# File 'lib/sfrest/usage.rb', line 40

def monthly(stack_id = 1, datum = {})
  datum[stack_id] = stack_id
  current_path = '/api/v1/dynamic-requests/monthly'
  @conn.get URI.parse(pb.build_url_query(current_path, datum)).to_s
end