Class: LaunchDarklyApi::MetricsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/launchdarkly_api/api/metrics_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ MetricsApi

Returns a new instance of MetricsApi.



19
20
21
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 19

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#delete_metric(project_key, metric_key, opts = {}) ⇒ nil

Delete metric Delete a metric by key.

Parameters:

  • project_key (String)

    The project key

  • metric_key (String)

    The metric key

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

    the optional parameters

Returns:

  • (nil)


28
29
30
31
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 28

def delete_metric(project_key, metric_key, opts = {})
  delete_metric_with_http_info(project_key, metric_key, opts)
  nil
end

#delete_metric_with_http_info(project_key, metric_key, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete metric Delete a metric by key.

Parameters:

  • project_key (String)

    The project key

  • metric_key (String)

    The metric key

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 39

def delete_metric_with_http_info(project_key, metric_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.delete_metric ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling MetricsApi.delete_metric"
  end
  # verify the required parameter 'metric_key' is set
  if @api_client.config.client_side_validation && metric_key.nil?
    fail ArgumentError, "Missing the required parameter 'metric_key' when calling MetricsApi.delete_metric"
  end
  # resource path
  local_var_path = '/api/v2/metrics/{projectKey}/{metricKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'metricKey' + '}', CGI.escape(metric_key.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'])

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

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

  # return_type
  return_type = opts[:debug_return_type]

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

  new_options = 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, new_options)
  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(project_key, metric_key, opts = {}) ⇒ MetricRep

Get metric Get information for a single metric from the specific project. ### Expanding the metric response LaunchDarkly supports four fields for expanding the "Get metric" response. By default, these fields are not included in the response. To expand the response, append the ‘expand` query parameter and add a comma-separated list with any of the following fields: - `experiments` includes all experiments from the specific project that use the metric - `experimentCount` includes the number of experiments from the specific project that use the metric - `metricGroups` includes all metric groups from the specific project that use the metric - `metricGroupCount` includes the number of metric groups from the specific project that use the metric For example, `expand=experiments` includes the `experiments` field in the response.

Parameters:

  • project_key (String)

    The project key

  • metric_key (String)

    The metric key

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

    the optional parameters

Options Hash (opts):

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response. Supported fields are &#x60;experiments&#x60;, &#x60;experimentCount&#x60;, &#x60;metricGroups&#x60;, &#x60;metricGroupCount&#x60;, &#x60;eventSources&#x60;, &#x60;guardedRollouts&#x60;, &#x60;guardedRolloutCount&#x60;, and &#x60;lastUsedInEntity&#x60;.

  • :version_id (String)

    The specific version ID of the metric

Returns:



99
100
101
102
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 99

def get_metric(project_key, metric_key, opts = {})
  data, _status_code, _headers = get_metric_with_http_info(project_key, metric_key, opts)
  data
end

#get_metric_with_http_info(project_key, metric_key, opts = {}) ⇒ Array<(MetricRep, Integer, Hash)>

Get metric Get information for a single metric from the specific project. ### Expanding the metric response LaunchDarkly supports four fields for expanding the &quot;Get metric&quot; response. By default, these fields are not included in the response. To expand the response, append the &#x60;expand&#x60; query parameter and add a comma-separated list with any of the following fields: - &#x60;experiments&#x60; includes all experiments from the specific project that use the metric - &#x60;experimentCount&#x60; includes the number of experiments from the specific project that use the metric - &#x60;metricGroups&#x60; includes all metric groups from the specific project that use the metric - &#x60;metricGroupCount&#x60; includes the number of metric groups from the specific project that use the metric For example, &#x60;expand&#x3D;experiments&#x60; includes the &#x60;experiments&#x60; field in the response.

Parameters:

  • project_key (String)

    The project key

  • metric_key (String)

    The metric key

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

    the optional parameters

Options Hash (opts):

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response. Supported fields are &#x60;experiments&#x60;, &#x60;experimentCount&#x60;, &#x60;metricGroups&#x60;, &#x60;metricGroupCount&#x60;, &#x60;eventSources&#x60;, &#x60;guardedRollouts&#x60;, &#x60;guardedRolloutCount&#x60;, and &#x60;lastUsedInEntity&#x60;.

  • :version_id (String)

    The specific version ID of the metric

Returns:

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

    MetricRep data, response status code and response headers



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
158
159
160
161
162
163
164
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 112

def get_metric_with_http_info(project_key, metric_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling MetricsApi.get_metric"
  end
  # verify the required parameter 'metric_key' is set
  if @api_client.config.client_side_validation && metric_key.nil?
    fail ArgumentError, "Missing the required parameter 'metric_key' when calling MetricsApi.get_metric"
  end
  # resource path
  local_var_path = '/api/v2/metrics/{projectKey}/{metricKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'metricKey' + '}', CGI.escape(metric_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?
  query_params[:'versionId'] = opts[:'version_id'] if !opts[:'version_id'].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] || 'MetricRep'

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

  new_options = 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, new_options)
  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

#get_metrics(project_key, opts = {}) ⇒ MetricCollectionRep

List metrics Get a list of all metrics for the specified project. ### Filtering metrics The ‘filter` parameter supports the following operators: `contains`, `equals`, `anyOf`. #### Supported fields and operators You can only filter certain fields in metrics when using the `filter` parameter. Additionally, you can only filter some fields with certain operators. When you search for metrics, the `filter` parameter supports the following fields and operators: |<div style="width:120px">Field</div> |Description |Supported operators | |—|—|—| | `eventKind` | The metric event kind. One of `custom`, `pageview`, `click`. | `equals` | | `hasConnections` | Whether the metric has connections to experiments or guarded rollouts. One of `true`, `false`. | `equals` | | `isNumeric` | Whether the metric is numeric. One of `true`, `false`. | `equals` | | `maintainerIds` | A comma-separated list of metric maintainer IDs. | `anyOf` | | `maintainerTeamKey` | The metric maintainer team key. | `equals` | | `query` | A "fuzzy" search across metric key and name. Supply a string or list of strings to the operator. | `equals` | | `tags` | The metric tags. | `contains` | | `unitAggregationType` | The metric’s unit aggregation type. One of ‘sum`, `average`. | `equals` | For example, the filter `?filter=tags contains ["tag1", "tag2", "tag3"]` matches metrics that have all three tags. The documented values for `filter` query parameters are prior to URL encoding. For example, the `[` in `?filter=tags contains ["tag1", "tag2", "tag3"]` must be encoded to `%5B`. ### Expanding the metric list response LaunchDarkly supports expanding the "List metrics" response. By default, the expandable field is not included in the response. To expand the response, append the `expand` query parameter and add the following supported field: - `experimentCount` includes the number of experiments from the specific project that use the metric For example, `expand=experimentCount` includes the `experimentCount` field for each metric in the response.

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Options Hash (opts):

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response.

  • :limit (Integer)

    The number of metrics to return in the response. Defaults to 20. Maximum limit is 50.

  • :offset (Integer)

    Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and returns the next &#x60;limit&#x60; items.

  • :sort (String)

    A field to sort the items by. Prefix field by a dash ( - ) to sort in descending order. This endpoint supports sorting by &#x60;createdAt&#x60; or &#x60;name&#x60;.

  • :filter (String)

    A comma-separated list of filters. This endpoint accepts filtering by &#x60;query&#x60;, &#x60;tags&#x60;, &#39;eventKind&#39;, &#39;isNumeric&#39;, &#39;unitAggregationType&#x60;, &#x60;hasConnections&#x60;, &#x60;maintainerIds&#x60;, &#x60;maintainerTeamKey&#x60; and &#x60;view&#x60;. To learn more about the filter syntax, read the &#39;Filtering metrics&#39; section above.

Returns:



176
177
178
179
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 176

def get_metrics(project_key, opts = {})
  data, _status_code, _headers = get_metrics_with_http_info(project_key, opts)
  data
end

#get_metrics_with_http_info(project_key, opts = {}) ⇒ Array<(MetricCollectionRep, Integer, Hash)>

List metrics Get a list of all metrics for the specified project. ### Filtering metrics The &#x60;filter&#x60; parameter supports the following operators: &#x60;contains&#x60;, &#x60;equals&#x60;, &#x60;anyOf&#x60;. #### Supported fields and operators You can only filter certain fields in metrics when using the &#x60;filter&#x60; parameter. Additionally, you can only filter some fields with certain operators. When you search for metrics, the &#x60;filter&#x60; parameter supports the following fields and operators: |&lt;div style&#x3D;&quot;width:120px&quot;&gt;Field&lt;/div&gt; |Description |Supported operators | |—|—|—| | &#x60;eventKind&#x60; | The metric event kind. One of &#x60;custom&#x60;, &#x60;pageview&#x60;, &#x60;click&#x60;. | &#x60;equals&#x60; | | &#x60;hasConnections&#x60; | Whether the metric has connections to experiments or guarded rollouts. One of &#x60;true&#x60;, &#x60;false&#x60;. | &#x60;equals&#x60; | | &#x60;isNumeric&#x60; | Whether the metric is numeric. One of &#x60;true&#x60;, &#x60;false&#x60;. | &#x60;equals&#x60; | | &#x60;maintainerIds&#x60; | A comma-separated list of metric maintainer IDs. | &#x60;anyOf&#x60; | | &#x60;maintainerTeamKey&#x60; | The metric maintainer team key. | &#x60;equals&#x60; | | &#x60;query&#x60; | A &quot;fuzzy&quot; search across metric key and name. Supply a string or list of strings to the operator. | &#x60;equals&#x60; | | &#x60;tags&#x60; | The metric tags. | &#x60;contains&#x60; | | &#x60;unitAggregationType&#x60; | The metric&#39;s unit aggregation type. One of &#x60;sum&#x60;, &#x60;average&#x60;. | &#x60;equals&#x60; | For example, the filter &#x60;?filter&#x3D;tags contains [&quot;tag1&quot;, &quot;tag2&quot;, &quot;tag3&quot;]&#x60; matches metrics that have all three tags. The documented values for &#x60;filter&#x60; query parameters are prior to URL encoding. For example, the &#x60;[&#x60; in &#x60;?filter&#x3D;tags contains [&quot;tag1&quot;, &quot;tag2&quot;, &quot;tag3&quot;]&#x60; must be encoded to &#x60;%5B&#x60;. ### Expanding the metric list response LaunchDarkly supports expanding the &quot;List metrics&quot; response. By default, the expandable field is not included in the response. To expand the response, append the &#x60;expand&#x60; query parameter and add the following supported field: - &#x60;experimentCount&#x60; includes the number of experiments from the specific project that use the metric For example, &#x60;expand&#x3D;experimentCount&#x60; includes the &#x60;experimentCount&#x60; field for each metric in the response.

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Options Hash (opts):

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response.

  • :limit (Integer)

    The number of metrics to return in the response. Defaults to 20. Maximum limit is 50.

  • :offset (Integer)

    Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and returns the next &#x60;limit&#x60; items.

  • :sort (String)

    A field to sort the items by. Prefix field by a dash ( - ) to sort in descending order. This endpoint supports sorting by &#x60;createdAt&#x60; or &#x60;name&#x60;.

  • :filter (String)

    A comma-separated list of filters. This endpoint accepts filtering by &#x60;query&#x60;, &#x60;tags&#x60;, &#39;eventKind&#39;, &#39;isNumeric&#39;, &#39;unitAggregationType&#x60;, &#x60;hasConnections&#x60;, &#x60;maintainerIds&#x60;, &#x60;maintainerTeamKey&#x60; and &#x60;view&#x60;. To learn more about the filter syntax, read the &#39;Filtering metrics&#39; section above.

Returns:

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

    MetricCollectionRep data, response status code and response headers



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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 191

def get_metrics_with_http_info(project_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_metrics ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling MetricsApi.get_metrics"
  end
  # resource path
  local_var_path = '/api/v2/metrics/{projectKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].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] || 'MetricCollectionRep'

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

  new_options = opts.merge(
    :operation => :"MetricsApi.get_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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#patch_metric(project_key, metric_key, patch_operation, opts = {}) ⇒ MetricRep

Update metric Patch a metric by key. Updating a metric uses a [JSON patch](datatracker.ietf.org/doc/html/rfc6902) representation of the desired changes. To learn more, read [Updates](launchdarkly.com/docs/api#updates).

Parameters:

  • project_key (String)

    The project key

  • metric_key (String)

    The metric key

  • patch_operation (Array<PatchOperation>)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



251
252
253
254
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 251

def patch_metric(project_key, metric_key, patch_operation, opts = {})
  data, _status_code, _headers = patch_metric_with_http_info(project_key, metric_key, patch_operation, opts)
  data
end

#patch_metric_with_http_info(project_key, metric_key, patch_operation, opts = {}) ⇒ Array<(MetricRep, Integer, Hash)>

Update metric Patch a metric by key. Updating a metric uses a [JSON patch](datatracker.ietf.org/doc/html/rfc6902) representation of the desired changes. To learn more, read [Updates](launchdarkly.com/docs/api#updates).

Parameters:

  • project_key (String)

    The project key

  • metric_key (String)

    The metric key

  • patch_operation (Array<PatchOperation>)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

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

    MetricRep data, response status code and response headers



263
264
265
266
267
268
269
270
271
272
273
274
275
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
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 263

def patch_metric_with_http_info(project_key, metric_key, patch_operation, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.patch_metric ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling MetricsApi.patch_metric"
  end
  # verify the required parameter 'metric_key' is set
  if @api_client.config.client_side_validation && metric_key.nil?
    fail ArgumentError, "Missing the required parameter 'metric_key' when calling MetricsApi.patch_metric"
  end
  # verify the required parameter 'patch_operation' is set
  if @api_client.config.client_side_validation && patch_operation.nil?
    fail ArgumentError, "Missing the required parameter 'patch_operation' when calling MetricsApi.patch_metric"
  end
  # resource path
  local_var_path = '/api/v2/metrics/{projectKey}/{metricKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'metricKey' + '}', CGI.escape(metric_key.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'])
  # 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

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

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(patch_operation)

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

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

  new_options = opts.merge(
    :operation => :"MetricsApi.patch_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(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#patch_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#post_metric(project_key, metric_post, opts = {}) ⇒ MetricRep

Create metric Create a new metric in the specified project. The expected ‘POST` body differs depending on the specified `kind` property.

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Returns:



330
331
332
333
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 330

def post_metric(project_key, metric_post, opts = {})
  data, _status_code, _headers = post_metric_with_http_info(project_key, metric_post, opts)
  data
end

#post_metric_with_http_info(project_key, metric_post, opts = {}) ⇒ Array<(MetricRep, Integer, Hash)>

Create metric Create a new metric in the specified project. The expected &#x60;POST&#x60; body differs depending on the specified &#x60;kind&#x60; property.

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Returns:

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

    MetricRep data, response status code and response headers



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
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
# File 'lib/launchdarkly_api/api/metrics_api.rb', line 341

def post_metric_with_http_info(project_key, metric_post, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.post_metric ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling MetricsApi.post_metric"
  end
  # verify the required parameter 'metric_post' is set
  if @api_client.config.client_side_validation && metric_post.nil?
    fail ArgumentError, "Missing the required parameter 'metric_post' when calling MetricsApi.post_metric"
  end
  # resource path
  local_var_path = '/api/v2/metrics/{projectKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.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'])
  # 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

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

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(metric_post)

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

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

  new_options = opts.merge(
    :operation => :"MetricsApi.post_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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#post_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end