Skip to content

Latest commit

 

History

History
521 lines (395 loc) · 21.2 KB

MetricsApi.md

File metadata and controls

521 lines (395 loc) · 21.2 KB

launchdarkly_api.MetricsApi

All URIs are relative to https://app.launchdarkly.com

Method HTTP request Description
delete_metric DELETE /api/v2/metrics/{projectKey}/{metricKey} Delete metric
get_metric GET /api/v2/metrics/{projectKey}/{metricKey} Get metric
get_metrics GET /api/v2/metrics/{projectKey} List metrics
patch_metric PATCH /api/v2/metrics/{projectKey}/{metricKey} Update metric
post_metric POST /api/v2/metrics/{projectKey} Create metric

delete_metric

delete_metric(project_key, metric_key)

Delete metric

Delete a metric by key.

Example

  • Api Key Authentication (ApiKey):
import time
import launchdarkly_api
from launchdarkly_api.api import metrics_api
from launchdarkly_api.model.forbidden_error_rep import ForbiddenErrorRep
from launchdarkly_api.model.not_found_error_rep import NotFoundErrorRep
from launchdarkly_api.model.rate_limited_error_rep import RateLimitedErrorRep
from launchdarkly_api.model.unauthorized_error_rep import UnauthorizedErrorRep
from pprint import pprint
# Defining the host is optional and defaults to https://app.launchdarkly.com
# See configuration.py for a list of all supported configuration parameters.
configuration = launchdarkly_api.Configuration(
    host = "https://app.launchdarkly.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKey
configuration.api_key['ApiKey'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKey'] = 'Bearer'

# Enter a context with an instance of the API client
with launchdarkly_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = metrics_api.MetricsApi(api_client)
    project_key = "projectKey_example" # str | The project key
    metric_key = "metricKey_example" # str | The metric key

    # example passing only required values which don't have defaults set
    try:
        # Delete metric
        api_instance.delete_metric(project_key, metric_key)
    except launchdarkly_api.ApiException as e:
        print("Exception when calling MetricsApi->delete_metric: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
metric_key str The metric key

Return type

void (empty response body)

Authorization

ApiKey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
204 Action succeeded -
401 Invalid access token -
403 Forbidden -
404 Invalid resource identifier -
429 Rate limited -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_metric

MetricRep get_metric(project_key, metric_key)

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.

Example

  • Api Key Authentication (ApiKey):
import time
import launchdarkly_api
from launchdarkly_api.api import metrics_api
from launchdarkly_api.model.forbidden_error_rep import ForbiddenErrorRep
from launchdarkly_api.model.metric_rep import MetricRep
from launchdarkly_api.model.not_found_error_rep import NotFoundErrorRep
from launchdarkly_api.model.rate_limited_error_rep import RateLimitedErrorRep
from launchdarkly_api.model.unauthorized_error_rep import UnauthorizedErrorRep
from pprint import pprint
# Defining the host is optional and defaults to https://app.launchdarkly.com
# See configuration.py for a list of all supported configuration parameters.
configuration = launchdarkly_api.Configuration(
    host = "https://app.launchdarkly.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKey
configuration.api_key['ApiKey'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKey'] = 'Bearer'

# Enter a context with an instance of the API client
with launchdarkly_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = metrics_api.MetricsApi(api_client)
    project_key = "projectKey_example" # str | The project key
    metric_key = "metricKey_example" # str | The metric key
    expand = "expand_example" # str | A comma-separated list of properties that can reveal additional information in the response. (optional)
    version_id = "versionId_example" # str | The specific version ID of the metric (optional)

    # example passing only required values which don't have defaults set
    try:
        # Get metric
        api_response = api_instance.get_metric(project_key, metric_key)
        pprint(api_response)
    except launchdarkly_api.ApiException as e:
        print("Exception when calling MetricsApi->get_metric: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Get metric
        api_response = api_instance.get_metric(project_key, metric_key, expand=expand, version_id=version_id)
        pprint(api_response)
    except launchdarkly_api.ApiException as e:
        print("Exception when calling MetricsApi->get_metric: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
metric_key str The metric key
expand str A comma-separated list of properties that can reveal additional information in the response. [optional]
version_id str The specific version ID of the metric [optional]

Return type

MetricRep

Authorization

ApiKey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Metric response -
401 Invalid access token -
403 Forbidden -
404 Invalid resource identifier -
429 Rate limited -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_metrics

MetricCollectionRep get_metrics(project_key)

List metrics

Get a list of all metrics for the specified project. ### Filtering metrics The filter parameter supports the following operators: contains. #### 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 |Description |Supported operators | |---|---|---| | tags | The metric tags. | contains | 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.

Example

  • Api Key Authentication (ApiKey):
import time
import launchdarkly_api
from launchdarkly_api.api import metrics_api
from launchdarkly_api.model.not_found_error_rep import NotFoundErrorRep
from launchdarkly_api.model.metric_collection_rep import MetricCollectionRep
from launchdarkly_api.model.unauthorized_error_rep import UnauthorizedErrorRep
from pprint import pprint
# Defining the host is optional and defaults to https://app.launchdarkly.com
# See configuration.py for a list of all supported configuration parameters.
configuration = launchdarkly_api.Configuration(
    host = "https://app.launchdarkly.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKey
configuration.api_key['ApiKey'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKey'] = 'Bearer'

# Enter a context with an instance of the API client
with launchdarkly_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = metrics_api.MetricsApi(api_client)
    project_key = "projectKey_example" # str | The project key
    expand = "expand_example" # str | A comma-separated list of properties that can reveal additional information in the response. (optional)
    limit = 1 # int | The number of metrics to return in the response. Defaults to 20. Maximum limit is 50. (optional)
    offset = 1 # int | 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 `limit` items. (optional)
    sort = "sort_example" # str | A field to sort the items by. Prefix field by a dash ( - ) to sort in descending order. This endpoint supports sorting by `createdAt` or `name`. (optional)
    filter = "filter_example" # str | A comma-separated list of filters. This endpoint only accepts filtering by `tags`. To learn more about the filter syntax, read the 'Filtering metrics' section above. (optional)

    # example passing only required values which don't have defaults set
    try:
        # List metrics
        api_response = api_instance.get_metrics(project_key)
        pprint(api_response)
    except launchdarkly_api.ApiException as e:
        print("Exception when calling MetricsApi->get_metrics: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # List metrics
        api_response = api_instance.get_metrics(project_key, expand=expand, limit=limit, offset=offset, sort=sort, filter=filter)
        pprint(api_response)
    except launchdarkly_api.ApiException as e:
        print("Exception when calling MetricsApi->get_metrics: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
expand str A comma-separated list of properties that can reveal additional information in the response. [optional]
limit int The number of metrics to return in the response. Defaults to 20. Maximum limit is 50. [optional]
offset int 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 `limit` items. [optional]
sort str A field to sort the items by. Prefix field by a dash ( - ) to sort in descending order. This endpoint supports sorting by `createdAt` or `name`. [optional]
filter str A comma-separated list of filters. This endpoint only accepts filtering by `tags`. To learn more about the filter syntax, read the 'Filtering metrics' section above. [optional]

Return type

MetricCollectionRep

Authorization

ApiKey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Metrics collection response -
401 Invalid access token -
404 Invalid resource identifier -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

patch_metric

MetricRep patch_metric(project_key, metric_key, json_patch)

Update metric

Patch a metric by key. Updating a metric uses a JSON patch representation of the desired changes. To learn more, read Updates.

Example

  • Api Key Authentication (ApiKey):
import time
import launchdarkly_api
from launchdarkly_api.api import metrics_api
from launchdarkly_api.model.json_patch import JSONPatch
from launchdarkly_api.model.invalid_request_error_rep import InvalidRequestErrorRep
from launchdarkly_api.model.metric_rep import MetricRep
from launchdarkly_api.model.not_found_error_rep import NotFoundErrorRep
from launchdarkly_api.model.rate_limited_error_rep import RateLimitedErrorRep
from launchdarkly_api.model.unauthorized_error_rep import UnauthorizedErrorRep
from launchdarkly_api.model.status_conflict_error_rep import StatusConflictErrorRep
from pprint import pprint
# Defining the host is optional and defaults to https://app.launchdarkly.com
# See configuration.py for a list of all supported configuration parameters.
configuration = launchdarkly_api.Configuration(
    host = "https://app.launchdarkly.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKey
configuration.api_key['ApiKey'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKey'] = 'Bearer'

# Enter a context with an instance of the API client
with launchdarkly_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = metrics_api.MetricsApi(api_client)
    project_key = "projectKey_example" # str | The project key
    metric_key = "metricKey_example" # str | The metric key
    json_patch = JSONPatch([
        PatchOperation(
            op="replace",
            path="/exampleField",
            value=None,
        ),
    ]) # JSONPatch | 

    # example passing only required values which don't have defaults set
    try:
        # Update metric
        api_response = api_instance.patch_metric(project_key, metric_key, json_patch)
        pprint(api_response)
    except launchdarkly_api.ApiException as e:
        print("Exception when calling MetricsApi->patch_metric: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
metric_key str The metric key
json_patch JSONPatch

Return type

MetricRep

Authorization

ApiKey

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Metric response -
400 Invalid request -
401 Invalid access token -
404 Invalid resource identifier -
409 Status conflict -
429 Rate limited -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

post_metric

MetricRep post_metric(project_key, metric_post)

Create metric

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

Example

  • Api Key Authentication (ApiKey):
import time
import launchdarkly_api
from launchdarkly_api.api import metrics_api
from launchdarkly_api.model.invalid_request_error_rep import InvalidRequestErrorRep
from launchdarkly_api.model.forbidden_error_rep import ForbiddenErrorRep
from launchdarkly_api.model.metric_rep import MetricRep
from launchdarkly_api.model.not_found_error_rep import NotFoundErrorRep
from launchdarkly_api.model.rate_limited_error_rep import RateLimitedErrorRep
from launchdarkly_api.model.metric_post import MetricPost
from launchdarkly_api.model.unauthorized_error_rep import UnauthorizedErrorRep
from launchdarkly_api.model.status_conflict_error_rep import StatusConflictErrorRep
from pprint import pprint
# Defining the host is optional and defaults to https://app.launchdarkly.com
# See configuration.py for a list of all supported configuration parameters.
configuration = launchdarkly_api.Configuration(
    host = "https://app.launchdarkly.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKey
configuration.api_key['ApiKey'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKey'] = 'Bearer'

# Enter a context with an instance of the API client
with launchdarkly_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = metrics_api.MetricsApi(api_client)
    project_key = "projectKey_example" # str | The project key
    metric_post = MetricPost(
        key="metric-key-123abc",
        name="Example metric",
        description="optional description",
        kind="custom",
        selector=".dropdown-toggle",
        urls=[
            UrlPost(
                kind="exact",
                url="url_example",
                substring="substring_example",
                pattern="pattern_example",
            ),
        ],
        is_active=True,
        is_numeric=False,
        unit="orders",
        event_key="sales generated",
        success_criteria="HigherThanBaseline",
        tags=["example-tag"],
        randomization_units=["user"],
        unit_aggregation_type="average",
        analysis_type="mean",
        percentile_value=95,
        event_default=MetricEventDefaultRep(
            disabled=True,
            value=3.14,
        ),
    ) # MetricPost | 

    # example passing only required values which don't have defaults set
    try:
        # Create metric
        api_response = api_instance.post_metric(project_key, metric_post)
        pprint(api_response)
    except launchdarkly_api.ApiException as e:
        print("Exception when calling MetricsApi->post_metric: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
metric_post MetricPost

Return type

MetricRep

Authorization

ApiKey

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
201 Metric response -
400 Invalid request -
401 Invalid access token -
403 Forbidden -
404 Invalid resource identifier -
409 Status conflict -
429 Rate limited -

[Back to top] [Back to API list] [Back to Model list] [Back to README]