Class: Appwrite::Usage
- Defined in:
- lib/appwrite/services/usage.rb
Instance Method Summary collapse
-
#initialize(client) ⇒ Usage
constructor
A new instance of Usage.
-
#list_events(queries: nil, total: nil) ⇒ UsageEventList
Query usage event metrics from the usage database.
-
#list_gauges(queries: nil, total: nil) ⇒ UsageGaugeList
Query usage gauge metrics (point-in-time resource snapshots) from the usage database.
Constructor Details
#initialize(client) ⇒ Usage
Returns a new instance of Usage.
6 7 8 |
# File 'lib/appwrite/services/usage.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#list_events(queries: nil, total: nil) ⇒ UsageEventList
Query usage event metrics from the usage database. Returns individual event
rows with full metadata. Pass Query objects as JSON strings to filter,
paginate, and order results. Supported query methods: equal,
greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset.
Supported filter attributes: metric, path, method, status, resource,
resourceId, country, userAgent, time (these match the underlying column
names — note that the response surfaces resource as resourceType and
country as countryCode). When no time filter is supplied the endpoint
defaults to the last 7 days. Default limit(100) is applied if none is
given; user-supplied limits are capped at 500. The total field is capped
at 5000 to keep counts predictable — pass total=false to skip the count
entirely.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/appwrite/services/usage.rb', line 27 def list_events(queries: nil, total: nil) api_path = '/usage/events' api_params = { queries: queries, total: total, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::UsageEventList ) end |
#list_gauges(queries: nil, total: nil) ⇒ UsageGaugeList
Query usage gauge metrics (point-in-time resource snapshots) from the usage
database. Returns individual gauge snapshots with metric, value, timestamp,
resourceType, and resourceId. Pass Query objects as JSON strings to filter,
paginate, and order results. Supported query methods: equal,
greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset.
Supported filter attributes: metric, time. Use orderDesc("time"), limit(1) to fetch the most recent snapshot. When no time filter is
supplied the endpoint defaults to the last 7 days. Default limit(100) is
applied if none is given; user-supplied limits are capped at 500. The
total field is capped at 5000 to keep counts predictable — pass
total=false to skip the count entirely.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/appwrite/services/usage.rb', line 64 def list_gauges(queries: nil, total: nil) api_path = '/usage/gauges' api_params = { queries: queries, total: total, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::UsageGaugeList ) end |