# LaunchDarkly

{% hint style="info" %}
The following documentation is for **LaunchDarkly v1.0.3** *(BDK)*.
{% endhint %}

## Overview

LaunchDarkly is a feature management platform that enables teams to deploy code safely and control feature releases through feature flags. This integration allows automated feature flag management, user targeting, and deployment workflow automation. Enhance development velocity and reduce deployment risks through controlled feature rollouts.

## Prerequisites

### 1. Required Books

The following Book(s) need to be added to your agent so it can learn and understand the automation procedures defined within them:

* **LaunchDarkly**

#### How to Add the Book(s)

1. Go to **Books** → **All Books**.
2. Search for the name of the book and click on it.
3. Click on <kbd>**Install**</kbd> or <kbd>**Add Connection**</kbd> to add the book to your agent.
4. If adding a connection, you'll be prompted for [**connectivity**](#connectivity) details.

## Connectivity

This section outlines the available methods for connecting to the Book, along with the required configuration details for each.

### Connect using Access Token

Creates a client with the provided access token

| Label        | Description                      | Type        |
| ------------ | -------------------------------- | ----------- |
| Access Token | a Launch Darkly API access token | `sensitive` |

## Procedures

### to create a flag in a project

Create a new feature flag within a given project.

**Input Concepts**

| Concept                             | Description                                                           | Type                    | Required | Default Value |
| ----------------------------------- | --------------------------------------------------------------------- | ----------------------- | -------- | ------------- |
| [`project`](#launch-darkly-project) | the project in which the new flag will be created                     | `launch darkly project` | Yes      | (no default)  |
| [`new flag`](#launch-darkly-flag)   | the flag object containing the configuration for the new feature flag | `launch darkly flag`    | Yes      | (no default)  |

**Output Concepts**

| Concept                         | Description                    | Type                 |
| ------------------------------- | ------------------------------ | -------------------- |
| [`answer`](#launch-darkly-flag) | the newly created feature flag | `launch darkly flag` |

**Examples**

```generic
the string is '{"name":"New Flag from Playground 2", "key":"new-flag-from-playground-2", "description":"A flag created from the playground"}'
get the string as json
use the above as the new flag
>>>
create the new flag in the test project
```

### to get some (flag's status)

Get the status of a feature flag in a specific environment.

**Input Concepts**

| Concept                                     | Description                                         | Type                        | Required | Default Value |
| ------------------------------------------- | --------------------------------------------------- | --------------------------- | -------- | ------------- |
| [`flag`](#launch-darkly-flag)               | the feature flag whose status will be retrieved     | `launch darkly flag`        | Yes      | (no default)  |
| [`environment`](#launch-darkly-environment) | the environment in which to check the flag's status | `launch darkly environment` | Yes      | (no default)  |

**Output Concepts**

| Concept                                       | Description                                                                 | Type                        |
| --------------------------------------------- | --------------------------------------------------------------------------- | --------------------------- |
| [`flag's status`](#launch-darkly-flag-status) | a flag status indicating whether the flag is enabled (on) or disabled (off) | `launch darkly flag status` |

**Examples**

```generic
get the test project's environment whose name is "test"
use the above as the environment
get the test project's flag whose key is "new-test-flag"
use the above as the test flag
>>>
get the test flag's status where
    the environment is the environment
```

### to get some (project's environments)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Get the environments of a project

**Input Concepts**

| Concept                             | Description             | Type                    | Required | Default Value |
| ----------------------------------- | ----------------------- | ----------------------- | -------- | ------------- |
| [`project`](#launch-darkly-project) | a Launch Darkly project | `launch darkly project` | Yes      | (no default)  |

**Output Concepts**

| Concept                                                | Description                      | Type                        |
| ------------------------------------------------------ | -------------------------------- | --------------------------- |
| [`project's environments`](#launch-darkly-environment) | a list of retrieved environments | `launch darkly environment` |

**Examples**

```generic
get a project whose name is "Kognitos - Test Project"
use the above as the test project
get the test project's environments
```

Get a single environment with name Test. It can also be filtered by environment key.

```generic
...
get the test project's environment whose name is "Test"
```

### to get some (project's flags)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Get the flags of a project

**Input Concepts**

| Concept                             | Description             | Type                    | Required | Default Value |
| ----------------------------------- | ----------------------- | ----------------------- | -------- | ------------- |
| [`project`](#launch-darkly-project) | a Launch Darkly project | `launch darkly project` | Yes      | (no default)  |

**Output Concepts**

| Concept                                  | Description               | Type                 |
| ---------------------------------------- | ------------------------- | -------------------- |
| [`project's flags`](#launch-darkly-flag) | a list of retrieved flags | `launch darkly flag` |

**Examples**

```generic
get a project whose name is "Kognitos - Test Project"
use the above as the test project
get the test project's flags
```

Get a single flag with key new-test-flag. It can also be filtered by flag name.

```generic
...
get the test project's flag whose key is "new-test-flag"
```

### to get some (projects)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Get the projects in Launch Darkly

**Output Concepts**

| Concept                              | Description                  | Type                    |
| ------------------------------------ | ---------------------------- | ----------------------- |
| [`projects`](#launch-darkly-project) | a list of retrieved projects | `launch darkly project` |

**Examples**

```generic
get some projects
```

Get a single project with name "Kognitos - Test Project". It can also be filtered by project key.

```generic
get some projects whose name is "Kognitos - Test Project"
```

### to toggle some flag

Toggle the state of a feature flag in a specific environment.

**Input Concepts**

| Concept                                     | Description                                                                          | Type                        | Required | Default Value |
| ------------------------------------------- | ------------------------------------------------------------------------------------ | --------------------------- | -------- | ------------- |
| [`flag`](#launch-darkly-flag)               | the feature flag to be toggled                                                       | `launch darkly flag`        | Yes      | (no default)  |
| [`environment`](#launch-darkly-environment) | the environment in which to toggle the flag                                          | `launch darkly environment` | Yes      | (no default)  |
| `on`                                        | a boolean indicating the desired state; True to enable the flag, False to disable it | `boolean`                   | Yes      | (no default)  |

**Output Concepts**

| Concept                                | Description                            | Type                        |
| -------------------------------------- | -------------------------------------- | --------------------------- |
| [`answer`](#launch-darkly-flag-status) | the updated status of the feature flag | `launch darkly flag status` |

**Examples**

```generic
toggle the test flag with
    the environment is the environment
    the on is 'true'
```

## Concepts

### Launch darkly project

A project in Launch Darkly

| Field Name | Description                                                           | Type   |
| ---------- | --------------------------------------------------------------------- | ------ |
| `id`       | The unique identifier of the project.                                 | `text` |
| `name`     | The human-readable name of the project.                               | `text` |
| `key`      | The project key used to reference it in API calls and configurations. | `text` |

### Launch darkly flag

A feature flag in a Launch Darkly project

| Field Name    | Description                                                                   | Type             |
| ------------- | ----------------------------------------------------------------------------- | ---------------- |
| `name`        | The human-readable name of the flag.                                          | `text`           |
| `key`         | The unique key used to reference the flag.                                    | `text`           |
| `description` | A description of what the flag does or is used for.                           | `optional[text]` |
| `project_key` | The key of the project this flag belongs to. May be None if not yet assigned. | `optional[text]` |

### Launch darkly environment

An environment in a Launch Darkly project

| Field Name    | Description                                                           | Type   |
| ------------- | --------------------------------------------------------------------- | ------ |
| `id`          | The unique identifier of the environment.                             | `text` |
| `name`        | The human-readable name of the environment.                           | `text` |
| `key`         | The environment key used in API calls and feature flag configuration. | `text` |
| `project_key` | The key of the project this environment belongs to.                   | `text` |

### Launch darkly flag status

The status of a feature flag in a certain environment

| Field Name    | Description                                                                 | Type      |
| ------------- | --------------------------------------------------------------------------- | --------- |
| `environment` | The environment in which the flag status is evaluated.                      | `json`    |
| `flag`        | The feature flag whose status is being represented.                         | `json`    |
| `is_on`       | Indicates whether the flag is currently enabled (True) or disabled (False). | `boolean` |
