Skip to content

Latest commit

 

History

History
678 lines (482 loc) · 31.3 KB

ContextsApi.md

File metadata and controls

678 lines (482 loc) · 31.3 KB

launchdarkly_api.ContextsApi

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

Method HTTP request Description
evaluate_context_instance POST /api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate Evaluate flags for context instance
get_context_attribute_names GET /api/v2/projects/{projectKey}/environments/{environmentKey}/context-attributes Get context attribute names
get_context_attribute_values GET /api/v2/projects/{projectKey}/environments/{environmentKey}/context-attributes/{attributeName} Get context attribute values
get_context_kinds_by_project_key GET /api/v2/projects/{projectKey}/context-kinds Get context kinds
get_contexts GET /api/v2/projects/{projectKey}/environments/{environmentKey}/contexts/{kind}/{key} Get contexts
put_context_kind PUT /api/v2/projects/{projectKey}/context-kinds/{key} Create or update context kind
search_contexts POST /api/v2/projects/{projectKey}/environments/{environmentKey}/contexts/search Search for contexts

evaluate_context_instance

ContextInstanceEvaluations evaluate_context_instance(project_key, environment_key, request_body, limit=limit, offset=offset, sort=sort, filter=filter)

Evaluate flags for context instance

Evaluate flags for a context instance, for example, to determine the expected flag variation. Do not use this API instead of an SDK. The LaunchDarkly SDKs are specialized for the tasks of evaluating feature flags in your application at scale and generating analytics events based on those evaluations. This API is not designed for that use case. Any evaluations you perform with this API will not be reflected in features such as flag statuses and flag insights. Context instances evaluated by this API will not appear in the Contexts list. To learn more, read Comparing LaunchDarkly's SDKs and REST API.

Filtering

LaunchDarkly supports the filter query param for filtering, with the following fields:

  • query filters for a string that matches against the flags' keys and names. It is not case sensitive. For example: filter=query equals dark-mode.
  • tags filters the list to flags that have all of the tags in the list. For example: filter=tags contains ["beta","q1"].

You can also apply multiple filters at once. For example, setting filter=query equals dark-mode, tags contains ["beta","q1"] matches flags which match the key or name dark-mode and are tagged beta and q1.

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.context_instance_evaluations import ContextInstanceEvaluations
from launchdarkly_api.rest import ApiException
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'] = os.environ["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 = launchdarkly_api.ContextsApi(api_client)
    project_key = 'project_key_example' # str | The project key
    environment_key = 'environment_key_example' # str | The environment key
    request_body = {"key":"user-key-123abc","kind":"user","otherAttribute":"other attribute value"} # Dict[str, object] | 
    limit = 56 # int | The number of feature flags to return. Defaults to -1, which returns all flags (optional)
    offset = 56 # int | Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and then returns the next items in the list, up to the query `limit`. (optional)
    sort = 'sort_example' # str | A comma-separated list of fields to sort by. Fields prefixed by a dash ( - ) sort in descending order (optional)
    filter = 'filter_example' # str | A comma-separated list of filters. Each filter is of the form `field operator value`. Supported fields are explained above. (optional)

    try:
        # Evaluate flags for context instance
        api_response = api_instance.evaluate_context_instance(project_key, environment_key, request_body, limit=limit, offset=offset, sort=sort, filter=filter)
        print("The response of ContextsApi->evaluate_context_instance:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling ContextsApi->evaluate_context_instance: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
environment_key str The environment key
request_body Dict[str, object]
limit int The number of feature flags to return. Defaults to -1, which returns all flags [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 then returns the next items in the list, up to the query `limit`. [optional]
sort str A comma-separated list of fields to sort by. Fields prefixed by a dash ( - ) sort in descending order [optional]
filter str A comma-separated list of filters. Each filter is of the form `field operator value`. Supported fields are explained above. [optional]

Return type

ContextInstanceEvaluations

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Flag evaluation collection response -
400 Invalid request -
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_context_attribute_names

ContextAttributeNamesCollection get_context_attribute_names(project_key, environment_key, filter=filter, limit=limit)

Get context attribute names

Get context attribute names.

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.context_attribute_names_collection import ContextAttributeNamesCollection
from launchdarkly_api.rest import ApiException
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'] = os.environ["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 = launchdarkly_api.ContextsApi(api_client)
    project_key = 'project_key_example' # str | The project key
    environment_key = 'environment_key_example' # str | The environment key
    filter = 'filter_example' # str | A comma-separated list of context filters. This endpoint only accepts `kind` filters, with the `equals` operator, and `name` filters, with the `startsWith` operator. To learn more about the filter syntax, read [Filtering contexts](https://launchdarkly.com/docs/ld-docs/api/contexts#filtering-contexts). (optional)
    limit = 56 # int | Specifies the maximum number of items in the collection to return (max: 100, default: 100) (optional)

    try:
        # Get context attribute names
        api_response = api_instance.get_context_attribute_names(project_key, environment_key, filter=filter, limit=limit)
        print("The response of ContextsApi->get_context_attribute_names:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling ContextsApi->get_context_attribute_names: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
environment_key str The environment key
filter str A comma-separated list of context filters. This endpoint only accepts `kind` filters, with the `equals` operator, and `name` filters, with the `startsWith` operator. To learn more about the filter syntax, read Filtering contexts. [optional]
limit int Specifies the maximum number of items in the collection to return (max: 100, default: 100) [optional]

Return type

ContextAttributeNamesCollection

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Context attribute names collection response -
400 Invalid request -
401 Invalid access token -
403 Forbidden -
429 Rate limited -

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

get_context_attribute_values

ContextAttributeValuesCollection get_context_attribute_values(project_key, environment_key, attribute_name, filter=filter, limit=limit)

Get context attribute values

Get context attribute values.

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.context_attribute_values_collection import ContextAttributeValuesCollection
from launchdarkly_api.rest import ApiException
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'] = os.environ["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 = launchdarkly_api.ContextsApi(api_client)
    project_key = 'project_key_example' # str | The project key
    environment_key = 'environment_key_example' # str | The environment key
    attribute_name = 'attribute_name_example' # str | The attribute name
    filter = 'filter_example' # str | A comma-separated list of context filters. This endpoint requires a `kind` filter, with the `equals` operator, and also accepts a `value` filter, with the `startsWith` operator. To learn more about the filter syntax, read [Filtering contexts](https://launchdarkly.com/docs/ld-docs/api/contexts#filtering-contexts). (optional)
    limit = 56 # int | Specifies the maximum number of items in the collection to return (max: 100, default: 50) (optional)

    try:
        # Get context attribute values
        api_response = api_instance.get_context_attribute_values(project_key, environment_key, attribute_name, filter=filter, limit=limit)
        print("The response of ContextsApi->get_context_attribute_values:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling ContextsApi->get_context_attribute_values: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
environment_key str The environment key
attribute_name str The attribute name
filter str A comma-separated list of context filters. This endpoint requires a `kind` filter, with the `equals` operator, and also accepts a `value` filter, with the `startsWith` operator. To learn more about the filter syntax, read Filtering contexts. [optional]
limit int Specifies the maximum number of items in the collection to return (max: 100, default: 50) [optional]

Return type

ContextAttributeValuesCollection

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Context attribute values collection response -
400 Invalid request -
401 Invalid access token -
403 Forbidden -
429 Rate limited -

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

get_context_kinds_by_project_key

ContextKindsCollectionRep get_context_kinds_by_project_key(project_key, expand=expand)

Get context kinds

Get all context kinds for a given project.

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.context_kinds_collection_rep import ContextKindsCollectionRep
from launchdarkly_api.rest import ApiException
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'] = os.environ["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 = launchdarkly_api.ContextsApi(api_client)
    project_key = 'project_key_example' # str | The project key
    expand = 'expand_example' # str | A comma-separated list of properties that can reveal additional information in the response. Options: `environmentObservations`. (optional)

    try:
        # Get context kinds
        api_response = api_instance.get_context_kinds_by_project_key(project_key, expand=expand)
        print("The response of ContextsApi->get_context_kinds_by_project_key:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling ContextsApi->get_context_kinds_by_project_key: %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. Options: `environmentObservations`. [optional]

Return type

ContextKindsCollectionRep

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Context kinds collection response -
401 Invalid access token -
403 Forbidden -
404 Invalid resource identifier -

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

get_contexts

Contexts get_contexts(project_key, environment_key, kind, key, limit=limit, continuation_token=continuation_token, sort=sort, filter=filter, include_total_count=include_total_count)

Get contexts

Get contexts based on kind and key. Returns one item for each application from which LaunchDarkly has received the context, with the applicationId field populated.

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.contexts import Contexts
from launchdarkly_api.rest import ApiException
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'] = os.environ["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 = launchdarkly_api.ContextsApi(api_client)
    project_key = 'project_key_example' # str | The project key
    environment_key = 'environment_key_example' # str | The environment key
    kind = 'kind_example' # str | The context kind
    key = 'key_example' # str | The context key
    limit = 56 # int | Specifies the maximum number of items in the collection to return (max: 50, default: 20) (optional)
    continuation_token = 'continuation_token_example' # str | An opaque cursor that identifies the next page of results. You can use this for pagination, however, we recommend using the `next` link we provide instead. (optional)
    sort = 'sort_example' # str | Deprecated. This endpoint does not support sorting. Requests that include this parameter are rejected with a `400` response, so omit it. Results are always sorted by context kind and key. (optional)
    filter = 'filter_example' # str | A comma-separated list of context filters. This endpoint only accepts an `applicationId` filter. To learn more about the filter syntax, read [Filtering contexts](https://launchdarkly.com/docs/ld-docs/api/contexts#filtering-contexts). (optional)
    include_total_count = True # bool | Specifies whether to include or omit the total count of matching contexts. Defaults to true. (optional)

    try:
        # Get contexts
        api_response = api_instance.get_contexts(project_key, environment_key, kind, key, limit=limit, continuation_token=continuation_token, sort=sort, filter=filter, include_total_count=include_total_count)
        print("The response of ContextsApi->get_contexts:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling ContextsApi->get_contexts: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
environment_key str The environment key
kind str The context kind
key str The context key
limit int Specifies the maximum number of items in the collection to return (max: 50, default: 20) [optional]
continuation_token str An opaque cursor that identifies the next page of results. You can use this for pagination, however, we recommend using the `next` link we provide instead. [optional]
sort str Deprecated. This endpoint does not support sorting. Requests that include this parameter are rejected with a `400` response, so omit it. Results are always sorted by context kind and key. [optional]
filter str A comma-separated list of context filters. This endpoint only accepts an `applicationId` filter. To learn more about the filter syntax, read Filtering contexts. [optional]
include_total_count bool Specifies whether to include or omit the total count of matching contexts. Defaults to true. [optional]

Return type

Contexts

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Contexts collection response -
400 Invalid request -
401 Invalid access token -
403 Forbidden -
429 Rate limited -

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

put_context_kind

UpsertResponseRep put_context_kind(project_key, key, upsert_context_kind_payload)

Create or update context kind

Create or update a context kind by key. Only the included fields will be updated.

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.upsert_context_kind_payload import UpsertContextKindPayload
from launchdarkly_api.models.upsert_response_rep import UpsertResponseRep
from launchdarkly_api.rest import ApiException
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'] = os.environ["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 = launchdarkly_api.ContextsApi(api_client)
    project_key = 'project_key_example' # str | The project key
    key = 'key_example' # str | The context kind key
    upsert_context_kind_payload = launchdarkly_api.UpsertContextKindPayload() # UpsertContextKindPayload | 

    try:
        # Create or update context kind
        api_response = api_instance.put_context_kind(project_key, key, upsert_context_kind_payload)
        print("The response of ContextsApi->put_context_kind:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling ContextsApi->put_context_kind: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
key str The context kind key
upsert_context_kind_payload UpsertContextKindPayload

Return type

UpsertResponseRep

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Context kind upsert response -
400 Invalid request -
401 Invalid access token -
403 Forbidden -
404 Invalid resource identifier -

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

search_contexts

Contexts search_contexts(project_key, environment_key, context_search, limit=limit, continuation_token=continuation_token, sort=sort, filter=filter, include_total_count=include_total_count)

Search for contexts

Search for contexts.

You can use either the query parameters or the request body parameters. If both are provided, there is an error.

Results are sorted by context kind and key. Each context appears once, with its most recently reported attributes. Results include contexts that LaunchDarkly has received within the last 30 days.

To learn more about the filter syntax, read Filtering contexts. To learn more about contexts, read Contexts.

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.context_search import ContextSearch
from launchdarkly_api.models.contexts import Contexts
from launchdarkly_api.rest import ApiException
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'] = os.environ["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 = launchdarkly_api.ContextsApi(api_client)
    project_key = 'project_key_example' # str | The project key
    environment_key = 'environment_key_example' # str | The environment key
    context_search = launchdarkly_api.ContextSearch() # ContextSearch | 
    limit = 56 # int | Specifies the maximum number of items in the collection to return (max: 50, default: 20) (optional)
    continuation_token = 'continuation_token_example' # str | An opaque cursor that identifies the next page of results. You can use this for pagination, however, we recommend using the `next` link we provide instead. (optional)
    sort = 'sort_example' # str | Deprecated. This endpoint does not support sorting. Requests that include this parameter are rejected with a `400` response, so omit it. Results are always sorted by context kind and key. (optional)
    filter = 'filter_example' # str | A comma-separated list of context filters. To learn more about the filter syntax, read [Filtering contexts](https://launchdarkly.com/docs/ld-docs/api/contexts#filtering-contexts). (optional)
    include_total_count = True # bool | Specifies whether to include or omit the total count of matching contexts. Defaults to true. The total count is approximate and may be omitted if it is unavailable. (optional)

    try:
        # Search for contexts
        api_response = api_instance.search_contexts(project_key, environment_key, context_search, limit=limit, continuation_token=continuation_token, sort=sort, filter=filter, include_total_count=include_total_count)
        print("The response of ContextsApi->search_contexts:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling ContextsApi->search_contexts: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
environment_key str The environment key
context_search ContextSearch
limit int Specifies the maximum number of items in the collection to return (max: 50, default: 20) [optional]
continuation_token str An opaque cursor that identifies the next page of results. You can use this for pagination, however, we recommend using the `next` link we provide instead. [optional]
sort str Deprecated. This endpoint does not support sorting. Requests that include this parameter are rejected with a `400` response, so omit it. Results are always sorted by context kind and key. [optional]
filter str A comma-separated list of context filters. To learn more about the filter syntax, read Filtering contexts. [optional]
include_total_count bool Specifies whether to include or omit the total count of matching contexts. Defaults to true. The total count is approximate and may be omitted if it is unavailable. [optional]

Return type

Contexts

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Contexts collection response -
400 Invalid request -
401 Invalid access token -
403 Forbidden -
429 Rate limited -

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