Skip to content

Latest commit

 

History

History
364 lines (251 loc) · 11 KB

File metadata and controls

364 lines (251 loc) · 11 KB

launchdarkly_api.LayersApi

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

Method HTTP request Description
create_layer POST /api/v2/projects/{projectKey}/layers Create layer
get_layers GET /api/v2/projects/{projectKey}/layers Get layers
update_layer PATCH /api/v2/projects/{projectKey}/layers/{layerKey} Update layer

create_layer

LayerRep create_layer(project_key, layer_post)

Create layer

Create a layer. Experiments running in the same layer are granted mutually-exclusive traffic.

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.layer_post import LayerPost
from launchdarkly_api.models.layer_rep import LayerRep
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.LayersApi(api_client)
    project_key = 'project_key_example' # str | The project key
    layer_post = launchdarkly_api.LayerPost() # LayerPost | 

    try:
        # Create layer
        api_response = api_instance.create_layer(project_key, layer_post)
        print("The response of LayersApi->create_layer:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling LayersApi->create_layer: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
layer_post LayerPost

Return type

LayerRep

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
201 Layer response -
400 Invalid request -
403 Forbidden -
404 Invalid resource identifier -
429 Rate limited -

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

get_layers

LayerCollectionRep get_layers(project_key, filter=filter)

Get layers

Get a collection of all layers for a project

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.layer_collection_rep import LayerCollectionRep
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.LayersApi(api_client)
    project_key = 'project_key_example' # str | The project key
    filter = 'filter_example' # str | A comma-separated list of filters. This endpoint only accepts filtering by `experimentKey`. The filter returns layers which include that experiment for the selected environment(s). For example: `filter=reservations.experimentKey contains expKey`. (optional)

    try:
        # Get layers
        api_response = api_instance.get_layers(project_key, filter=filter)
        print("The response of LayersApi->get_layers:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling LayersApi->get_layers: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
filter str A comma-separated list of filters. This endpoint only accepts filtering by `experimentKey`. The filter returns layers which include that experiment for the selected environment(s). For example: `filter=reservations.experimentKey contains expKey`. [optional]

Return type

LayerCollectionRep

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Layer Collection response -
400 Invalid request -
403 Forbidden -
404 Invalid resource identifier -
429 Rate limited -

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

update_layer

LayerRep update_layer(project_key, layer_key, layer_patch_input)

Update layer

Update a layer by adding, changing, or removing traffic reservations for experiments, or by changing layer name or description. Updating a layer uses the semantic patch format.

To make a semantic patch request, you must append domain-model=launchdarkly.semanticpatch to your Content-Type header. To learn more, read Updates using semantic patch.

Instructions

Semantic patch requests support the following kind instructions for updating layers.

Click to expand instructions for updating layers

updateName

Updates the layer name.

Parameters
  • name: The new layer name.

Here's an example:

{
  "instructions": [{
      "kind": "updateName",
      "name": "New name"
  }]
}

updateDescription

Updates the layer description.

Parameters
  • description: The new description.

Here's an example:

{
  "instructions": [{
      "kind": "updateDescription",
      "description": "New description"
  }]
}

updateExperimentReservation

Adds or updates a traffic reservation for an experiment in a layer.

Parameters
  • experimentKey: The key of the experiment whose reservation you are adding to or updating in the layer.
  • reservationPercent: The amount of traffic in the layer to reserve. Must be an integer. Zero is allowed until iteration start.

Here's an example:

{
  "environmentKey": "production",
  "instructions": [{
      "kind": "updateExperimentReservation",
      "experimentKey": "exp-key",
      "reservationPercent": 10
  }]
}

removeExperiment

Removes a traffic reservation for an experiment from a layer.

Parameters
  • experimentKey: The key of the experiment whose reservation you want to remove from the layer.

Here's an example:

{
  "environmentKey": "production",
  "instructions": [{
      "kind": "removeExperiment",
      "experimentKey": "exp-key"
  }]
}

Example

  • Api Key Authentication (ApiKey):
import launchdarkly_api
from launchdarkly_api.models.layer_patch_input import LayerPatchInput
from launchdarkly_api.models.layer_rep import LayerRep
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.LayersApi(api_client)
    project_key = 'project_key_example' # str | The project key
    layer_key = 'layer_key_example' # str | The layer key
    layer_patch_input = {"comment":"Example comment describing the update","environmentKey":"production","instructions":[{"experimentKey":"checkout-button-color","kind":"updateExperimentReservation","reservationPercent":25}]} # LayerPatchInput | 

    try:
        # Update layer
        api_response = api_instance.update_layer(project_key, layer_key, layer_patch_input)
        print("The response of LayersApi->update_layer:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling LayersApi->update_layer: %s\n" % e)

Parameters

Name Type Description Notes
project_key str The project key
layer_key str The layer key
layer_patch_input LayerPatchInput

Return type

LayerRep

Authorization

ApiKey

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Layer response -
400 Invalid request -
403 Forbidden -
404 Invalid resource identifier -
429 Rate limited -

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