This repository contains a client library for LaunchDarkly's REST API. This client was automatically generated from our OpenAPI specification.
This REST API is for custom integrations, data export, or automating your feature flag workflows. DO NOT use this client library to include feature flags in your web or mobile application. To integrate feature flags with your application, please see the SDK documentation
Build custom integrations with the LaunchDarkly REST API
This Python package is automatically generated by the Swagger Codegen project:
- API version: 2.0.15
- Package version: 2.0.15
- Build package: io.swagger.codegen.languages.PythonClientCodegen For more information, please visit https://support.launchdarkly.com
Python 2.7 and 3.4+
If the python package is hosted on Github, you can install directly from Github
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)
Then import the package:
import launchdarkly_api Install via Setuptools.
python setup.py install --user(or sudo python setup.py install to install the package for all users)
Then import the package:
import launchdarkly_apiPlease follow the installation procedure and then run the following:
from __future__ import print_function
import time
import launchdarkly_api
from launchdarkly_api.rest import ApiException
from pprint import pprint
# Configure API key authorization: Token
configuration = launchdarkly_api.Configuration()
configuration.api_key['Authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Authorization'] = 'Bearer'
# create an instance of the API class
api_instance = launchdarkly_api.AuditLogApi(launchdarkly_api.ApiClient(configuration))
before = 789 # int | A timestamp filter, expressed as a Unix epoch time in milliseconds. All entries returned will have before this timestamp. (optional)
after = 789 # int | A timestamp filter, expressed as a Unix epoch time in milliseconds. All entries returned will have occured after this timestamp. (optional)
q = 'q_example' # str | Text to search for. You can search for the full or partial name of the resource involved or fullpartial email address of the member who made the change. (optional)
limit = 8.14 # float | A limit on the number of audit log entries to be returned, between 1 and 20. (optional)
spec = 'spec_example' # str | A resource specifier, allowing you to filter audit log listings by resource. (optional)
try:
# Get a list of all audit log entries. The query parameters allow you to restrict the returned results by date ranges, resource specifiers, or a full-text search query.
api_response = api_instance.get_audit_log_entries(before=before, after=after, q=q, limit=limit, spec=spec)
pprint(api_response)
except ApiException as e:
print("Exception when calling AuditLogApi->get_audit_log_entries: %s\n" % e)All URIs are relative to https://app.launchdarkly.com/api/v2
| Class | Method | HTTP request | Description |
|---|---|---|---|
| AuditLogApi | get_audit_log_entries | GET /auditlog | Get a list of all audit log entries. The query parameters allow you to restrict the returned results by date ranges, resource specifiers, or a full-text search query. |
| AuditLogApi | get_audit_log_entry | GET /auditlog/{resourceId} | Use this endpoint to fetch a single audit log entry by its resouce ID. |
| CustomRolesApi | delete_custom_role | DELETE /roles/{customRoleKey} | Delete a custom role by key. |
| CustomRolesApi | get_custom_role | GET /roles/{customRoleKey} | Get one custom role by key. |
| CustomRolesApi | get_custom_roles | GET /roles | Return a complete list of custom roles. |
| CustomRolesApi | patch_custom_role | PATCH /roles/{customRoleKey} | Modify a custom role by key. |
| CustomRolesApi | post_custom_role | POST /roles | Create a new custom role. |
| EnvironmentsApi | delete_environment | DELETE /projects/{projectKey}/environments/{environmentKey} | Delete an environment in a specific project. |
| EnvironmentsApi | get_environment | GET /projects/{projectKey}/environments/{environmentKey} | Get an environment given a project and key. |
| EnvironmentsApi | patch_environment | PATCH /projects/{projectKey}/environments/{environmentKey} | Modify an environment by ID. |
| EnvironmentsApi | post_environment | POST /projects/{projectKey}/environments | Create a new environment in a specified project with a given name, key, and swatch color. |
| FeatureFlagsApi | copy_feature_flag | POST /flags/{projectKey}/{environmentKey}/{featureFlagKey}/copy | Copies the feature flag configuration from one environment to the same feature flag in another environment. |
| FeatureFlagsApi | delete_feature_flag | DELETE /flags/{projectKey}/{featureFlagKey} | Delete a feature flag in all environments. Be careful-- only delete feature flags that are no longer being used by your application. |
| FeatureFlagsApi | get_feature_flag | GET /flags/{projectKey}/{featureFlagKey} | Get a single feature flag by key. |
| FeatureFlagsApi | get_feature_flag_status | GET /flag-statuses/{projectKey}/{environmentKey}/{featureFlagKey} | Get the status for a particular feature flag. |
| FeatureFlagsApi | get_feature_flag_statuses | GET /flag-statuses/{projectKey}/{environmentKey} | Get a list of statuses for all feature flags. The status includes the last time the feature flag was requested, as well as the state of the flag. |
| FeatureFlagsApi | get_feature_flags | GET /flags/{projectKey} | Get a list of all features in the given project. |
| FeatureFlagsApi | patch_feature_flag | PATCH /flags/{projectKey}/{featureFlagKey} | Perform a partial update to a feature. |
| FeatureFlagsApi | post_feature_flag | POST /flags/{projectKey} | Creates a new feature flag. |
| ProjectsApi | delete_project | DELETE /projects/{projectKey} | Delete a project by key. Caution-- deleting a project will delete all associated environments and feature flags. You cannot delete the last project in an account. |
| ProjectsApi | get_project | GET /projects/{projectKey} | Fetch a single project by key. |
| ProjectsApi | get_projects | GET /projects | Returns a list of all projects in the account. |
| ProjectsApi | patch_project | PATCH /projects/{projectKey} | Modify a project by ID. |
| ProjectsApi | post_project | POST /projects | Create a new project with the given key and name. |
| RootApi | get_root | GET / | |
| TeamMembersApi | delete_member | DELETE /members/{memberId} | Delete a team member by ID. |
| TeamMembersApi | get_member | GET /members/{memberId} | Get a single team member by ID. |
| TeamMembersApi | get_members | GET /members | Returns a list of all members in the account. |
| TeamMembersApi | patch_member | PATCH /members/{memberId} | Modify a team member by ID. |
| TeamMembersApi | post_members | POST /members | Invite new members. |
| UserSegmentsApi | delete_user_segment | DELETE /segments/{projectKey}/{environmentKey}/{userSegmentKey} | Delete a user segment. |
| UserSegmentsApi | get_user_segment | GET /segments/{projectKey}/{environmentKey}/{userSegmentKey} | Get a single user segment by key. |
| UserSegmentsApi | get_user_segments | GET /segments/{projectKey}/{environmentKey} | Get a list of all user segments in the given project. |
| UserSegmentsApi | patch_user_segment | PATCH /segments/{projectKey}/{environmentKey}/{userSegmentKey} | Perform a partial update to a user segment. |
| UserSegmentsApi | post_user_segment | POST /segments/{projectKey}/{environmentKey} | Creates a new user segment. |
| UserSettingsApi | get_user_flag_setting | GET /users/{projectKey}/{environmentKey}/{userKey}/flags/{featureFlagKey} | Fetch a single flag setting for a user by key. |
| UserSettingsApi | get_user_flag_settings | GET /users/{projectKey}/{environmentKey}/{userKey}/flags | Fetch a single flag setting for a user by key. |
| UserSettingsApi | put_flag_setting | PUT /users/{projectKey}/{environmentKey}/{userKey}/flags/{featureFlagKey} | Specifically enable or disable a feature flag for a user based on their key. |
| UsersApi | delete_user | DELETE /users/{projectKey}/{environmentKey}/{userKey} | Delete a user by ID. |
| UsersApi | get_search_users | GET /user-search/{projectKey}/{environmentKey} | Search users in LaunchDarkly based on their last active date, or a search query. It should not be used to enumerate all users in LaunchDarkly-- use the List users API resource. |
| UsersApi | get_user | GET /users/{projectKey}/{environmentKey}/{userKey} | Get a user by key. |
| UsersApi | get_users | GET /users/{projectKey}/{environmentKey} | List all users in the environment. Includes the total count of users. In each page, there will be up to 'limit' users returned (default 20). This is useful for exporting all users in the system for further analysis. Paginated collections will include a next link containing a URL with the next set of elements in the collection. |
| WebhooksApi | delete_webhook | DELETE /webhooks/{resourceId} | Delete a webhook by ID. |
| WebhooksApi | get_webhook | GET /webhooks/{resourceId} | Get a webhook by ID. |
| WebhooksApi | get_webhooks | GET /webhooks | Fetch a list of all webhooks. |
| WebhooksApi | patch_webhook | PATCH /webhooks/{resourceId} | Modify a webhook by ID. |
| WebhooksApi | post_webhook | POST /webhooks | Create a webhook. |
- AuditLogEntries
- AuditLogEntry
- AuditLogEntryTarget
- Clause
- CustomProperty
- CustomRole
- CustomRoleBody
- CustomRoles
- Environment
- EnvironmentPost
- Fallthrough
- FeatureFlag
- FeatureFlagBody
- FeatureFlagConfig
- FeatureFlagStatus
- FeatureFlagStatuses
- FeatureFlags
- Id
- Link
- Links
- Member
- Members
- MembersBody
- PatchComment
- PatchOperation
- Policy
- Prerequisite
- Project
- ProjectBody
- Projects
- Role
- Rollout
- Rule
- Statement
- Statements
- Target
- User
- UserFlagSetting
- UserFlagSettings
- UserRecord
- UserSegment
- UserSegmentBody
- UserSegmentRule
- UserSegments
- UserSettingsBody
- Users
- Variation
- Webhook
- WebhookBody
- Webhooks
- WeightedVariation
- Type: API key
- API key parameter name: Authorization
- Location: HTTP header
from __future__ import print_function
import os
from pprint import pprint
import launchdarkly_api
import launchdarkly_api.models
from launchdarkly_api.rest import ApiException
configuration = launchdarkly_api.Configuration()
configuration.api_key['Authorization'] = os.getenv("LD_API_KEY")
client = launchdarkly_api.ApiClient(configuration)
api_instance = launchdarkly_api.FeatureFlagsApi(client)
project_key = "openapi"
flag_key = "test-python"
# Create a flag with json variations
feature_flag_body = launchdarkly_api.FeatureFlagBody(
name=flag_key,
key=flag_key,
variations=[
launchdarkly_api.models.Variation(value=[1, 2]),
launchdarkly_api.models.Variation(value=[3, 4]),
launchdarkly_api.models.Variation(value=[5])
])
try:
api_response = api_instance.post_feature_flag(project_key, feature_flag_body)
pprint(api_response)
except ApiException as e:
print("Exception creating flag: %s\n" % e)
# Clean up the flag
try:
api_response = api_instance.delete_feature_flag(project_key, flag_key)
pprint(api_response)
except ApiException as e:
print("Exception deleting flag: %s\n" % e)