Class: Shipeasy::Admin::Generated::MetricsApi
- Inherits:
-
Object
- Object
- Shipeasy::Admin::Generated::MetricsApi
- Defined in:
- lib/shipeasy_admin/api/metrics_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#create_metric(create_metric_request, opts = {}) ⇒ CreateMetricResponse
Create a metric Creates an event-backed metric.
-
#create_metric_with_http_info(create_metric_request, opts = {}) ⇒ Array<(CreateMetricResponse, Integer, Hash)>
Create a metric Creates an event-backed metric.
-
#delete_metric(id, opts = {}) ⇒ DeleteMetricResponse
Archive a metric Soft-deletes (archives) the metric.
-
#delete_metric_with_http_info(id, opts = {}) ⇒ Array<(DeleteMetricResponse, Integer, Hash)>
Archive a metric Soft-deletes (archives) the metric.
-
#get_metric(id, opts = {}) ⇒ GetMetricResponse
Get a metric Fetch one metric by its id or name, including the rendered DSL query and the typed IR.
-
#get_metric_with_http_info(id, opts = {}) ⇒ Array<(GetMetricResponse, Integer, Hash)>
Get a metric Fetch one metric by its id or name, including the rendered DSL query and the typed IR.
-
#initialize(api_client = ApiClient.default) ⇒ MetricsApi
constructor
A new instance of MetricsApi.
-
#list_metrics(opts = {}) ⇒ Array<ListMetricsResponseInner>
List metrics Returns every metric in the project (not paginated) — name, folder, source event, aggregation, and the rendered query.
-
#list_metrics_with_http_info(opts = {}) ⇒ Array<(Array<ListMetricsResponseInner>, Integer, Hash)>
List metrics Returns every metric in the project (not paginated) — name, folder, source event, aggregation, and the rendered query.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ MetricsApi
Returns a new instance of MetricsApi.
19 20 21 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#create_metric(create_metric_request, opts = {}) ⇒ CreateMetricResponse
Create a metric
Creates an event-backed metric. Pass the query as the DSL string (query) or the typed IR (query_ir) — exactly one. event_name must equal the event the query references. Returns 409 if a metric with the same name already exists, and 422 if the query is invalid or references an unregistered event / label. Use cases - Track an event — count_users(<event>) for unique-user counts. - Sum a value — sum(<event>, <label>) for revenue / quantity metrics. - Experiment success metric — create the metric, then attach its id to an experiment.
28 29 30 31 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 28 def create_metric(create_metric_request, opts = {}) data, _status_code, _headers = create_metric_with_http_info(create_metric_request, opts) data end |
#create_metric_with_http_info(create_metric_request, opts = {}) ⇒ Array<(CreateMetricResponse, Integer, Hash)>
Create a metric Creates an event-backed metric. Pass the query as the DSL string (`query`) or the typed IR (`query_ir`) — exactly one. `event_name` must equal the event the query references. Returns `409` if a metric with the same `name` already exists, and `422` if the query is invalid or references an unregistered event / label. Use cases - Track an event — `count_users(<event>)` for unique-user counts. - Sum a value — `sum(<event>, <label>)` for revenue / quantity metrics. - Experiment success metric — create the metric, then attach its id to an experiment.
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 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 39 def create_metric_with_http_info(create_metric_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.create_metric ...' end # verify the required parameter 'create_metric_request' is set if @api_client.config.client_side_validation && create_metric_request.nil? fail ArgumentError, "Missing the required parameter 'create_metric_request' when calling MetricsApi.create_metric" end # resource path local_var_path = '/api/admin/metrics' # 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']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(create_metric_request) # return_type return_type = opts[:debug_return_type] || 'CreateMetricResponse' # auth_names auth_names = opts[:debug_auth_names] || ['bearerSdkKey'] = opts.merge( :operation => :"MetricsApi.create_metric", :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(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#create_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#delete_metric(id, opts = {}) ⇒ DeleteMetricResponse
Archive a metric
Soft-deletes (archives) the metric. Returns 409 if it is attached to a running experiment — stop those experiments first. Use case: Retire a metric once no running experiment depends on it (the user-facing verb is archive).
99 100 101 102 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 99 def delete_metric(id, opts = {}) data, _status_code, _headers = delete_metric_with_http_info(id, opts) data end |
#delete_metric_with_http_info(id, opts = {}) ⇒ Array<(DeleteMetricResponse, Integer, Hash)>
Archive a metric Soft-deletes (archives) the metric. Returns `409` if it is attached to a running experiment — stop those experiments first. Use case: Retire a metric once no running experiment depends on it (the user-facing verb is `archive`).
110 111 112 113 114 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 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 110 def delete_metric_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.delete_metric ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.delete_metric" end # resource path local_var_path = '/api/admin/metrics/{id}'.sub('{id}', CGI.escape(id.to_s)) # 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']) unless header_params['Accept'] header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'DeleteMetricResponse' # auth_names auth_names = opts[:debug_auth_names] || ['bearerSdkKey'] = opts.merge( :operation => :"MetricsApi.delete_metric", :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(:DELETE, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#delete_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_metric(id, opts = {}) ⇒ GetMetricResponse
Get a metric Fetch one metric by its id or name, including the rendered DSL query and the typed IR. Use case: Inspect a single metric's full definition before reusing it in an experiment or alert rule.
165 166 167 168 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 165 def get_metric(id, opts = {}) data, _status_code, _headers = get_metric_with_http_info(id, opts) data end |
#get_metric_with_http_info(id, opts = {}) ⇒ Array<(GetMetricResponse, Integer, Hash)>
Get a metric Fetch one metric by its id or name, including the rendered DSL query and the typed IR. Use case: Inspect a single metric's full definition before reusing it in an experiment or alert rule.
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 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 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 176 def get_metric_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric ...' end # resource path local_var_path = '/api/admin/metrics/{id}'.sub('{id}', CGI.escape(id.to_s)) # 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']) unless header_params['Accept'] header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'GetMetricResponse' # auth_names auth_names = opts[:debug_auth_names] || ['bearerSdkKey'] = opts.merge( :operation => :"MetricsApi.get_metric", :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#list_metrics(opts = {}) ⇒ Array<ListMetricsResponseInner>
List metrics Returns every metric in the project (not paginated) — name, folder, source event, aggregation, and the rendered query. Use case: Audit every metric defined in the project — for example to find the metric id to attach as an experiment's success metric.
226 227 228 229 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 226 def list_metrics(opts = {}) data, _status_code, _headers = list_metrics_with_http_info(opts) data end |
#list_metrics_with_http_info(opts = {}) ⇒ Array<(Array<ListMetricsResponseInner>, Integer, Hash)>
List metrics Returns every metric in the project (not paginated) — name, folder, source event, aggregation, and the rendered query. Use case: Audit every metric defined in the project — for example to find the metric id to attach as an experiment's success metric.
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 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/shipeasy_admin/api/metrics_api.rb', line 236 def list_metrics_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.list_metrics ...' end # resource path local_var_path = '/api/admin/metrics' # 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']) unless header_params['Accept'] header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Array<ListMetricsResponseInner>' # auth_names auth_names = opts[:debug_auth_names] || ['bearerSdkKey'] = opts.merge( :operation => :"MetricsApi.list_metrics", :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#list_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |