Skip to content

Latest commit

 

History

History
676 lines (525 loc) · 28.9 KB

API.md

File metadata and controls

676 lines (525 loc) · 28.9 KB

Classes

LaunchDarklyApiClient
LaunchDarklyLogger
LaunchDarklyUtils
LaunchDarklyUtilsFlags
LaunchDarklyUtilsMembers
LaunchDarklyUtilsProjects
LaunchDarklyUtilsRoles

LaunchDarklyApiClient

Kind: global class

LaunchDarklyApiClient.create(API_TOKEN, log, openapiJsonString) ⇒ Promise

Used internally by LaunchDarklyUtils to create an instance of Swagger apiClient with interceptors configured

Kind: static method of LaunchDarklyApiClient
Fulfil: Swagger apiClient generated by swagger-js
Reject: Error object with message

Param Type Description
API_TOKEN string from LaunchDarkly dashboard
log Object logger implementation
openapiJsonString string optional serialized json

LaunchDarklyLogger

Kind: global class

LaunchDarklyLogger.logger() ⇒ Logger

Get handle on Bunyan logger. This is the default logger if not supplied to utils.

Kind: static method of LaunchDarklyLogger

LaunchDarklyUtils

Kind: global class

launchDarklyUtils.create(API_TOKEN, customLogger, swaggerYamlString) ⇒ Promise

Create an instance of ldutils with api specific classes attached. This is the primary class used to access apis, as api grouping util classes are attached to this class.

Kind: instance method of LaunchDarklyUtils
Fulfil: LaunchDarklyUtils
Reject: Error object with message

Param Type Description
API_TOKEN string from LaunchDarkly dashboard
customLogger Object logger implementation, or 'console'. If not supplied, defaults to Bunyan logger
swaggerYamlString string optional serialized yaml

LaunchDarklyUtilsFlags

Kind: global class

new LaunchDarklyUtilsFlags(apiClient, log, ldUtils)

Feature flag specific api functions attached as 'LaunchDarklyUtils.flags'

Returns: LaunchDarklyUtilsFlags - feature flag api functions

Param Type Description
apiClient Swagger generated launchdarkly apiClient
log Object logger implementation, or 'console'
ldUtils LaunchDarklyUtils primary utils class

launchDarklyUtilsFlags.API_GROUP ⇒ string

Api group object key in LD api

Kind: instance property of LaunchDarklyUtilsFlags

launchDarklyUtilsFlags.getFeatureFlags(projectKey) ⇒ Promise

Get all feature flags in project

Kind: instance method of LaunchDarklyUtilsFlags
Fulfil: Object feature flag list json
Reject: Error object with message

Param Type Description
projectKey string project identifier

Example

ldutils getFeatureFlags my-project

launchDarklyUtilsFlags.getFeatureFlag(projectKey, featureFlagKey, environmentKeyQuery) ⇒ Promise

Get a single feature flag by key, and optional environment

Kind: instance method of LaunchDarklyUtilsFlags
Fulfil: Object feature flag json
Reject: Error object with message

Param Type Description
projectKey string project identifier
featureFlagKey string feature flag identifier
environmentKeyQuery string optional environment name

Example

ldutils getFeatureFlag my-project my-flag dev

launchDarklyUtilsFlags.getFeatureFlagState(projectKey, featureFlagKey, environmentKeyQuery) ⇒ Promise

Get the boolean state of a single feature flag by key, and optional environment

Kind: instance method of LaunchDarklyUtilsFlags
Fulfil: boolean true/false
Reject: Error object with message

Param Type Description
projectKey string project identifier
featureFlagKey string feature flag identifier
environmentKeyQuery string environment name

Example

ldutils getFeatureFlagState my-project my-flag dev

launchDarklyUtilsFlags.updateFeatureFlag(projectKey, featureFlagKey, patch) ⇒ Promise

patch a feature flag by key

Kind: instance method of LaunchDarklyUtilsFlags
Fulfil: Object updated feature flag json
Reject: Error object with message

Param Type Description
projectKey string project identifier
featureFlagKey string feature flag identifier
patch Array.<Object> array of valid json patch descriptors

Example

ldutils updateFeatureFlag my-project my-flag {jsonPatch}

launchDarklyUtilsFlags.toggleFeatureFlag(projectKey, featureFlagKey, environmentKeyQuery, value) ⇒ Promise

Set the boolean state of a single feature flag by key, and environment name

Kind: instance method of LaunchDarklyUtilsFlags
Fulfil: Object updated feature flag json
Reject: Error object with message

Param Type Description
projectKey string project identifier
featureFlagKey string feature flag identifier
environmentKeyQuery string environment name
value boolean true or false

Example

ldutils toggleFeatureFlag my-project my-flag dev true

launchDarklyUtilsFlags.migrateFeatureFlag(projectKey, featureFlagKey, fromEnv, toEnv, includeState) ⇒ Promise

Migrate feature flag properties between environments in a project. this includes: targets, rules, fallthrough, offVariation, prerequisites and optionally the flags on/off state.

Kind: instance method of LaunchDarklyUtilsFlags
Fulfil: Object updated feature flag json
Reject: Error object with message

Param Type Description
projectKey string project identifier
featureFlagKey string feature flag identifier
fromEnv string environment to copy flag attributes from
toEnv string environment to copy flag attributes to
includeState boolean optionally copy boolean state true/false

Example

ldutils migrateFeatureFlag my-project my-flag dev test

launchDarklyUtilsFlags.bulkMigrateFeatureFlags(projectKey, featureFlagKeys, fromEnv, toEnv, includeState) ⇒ Promise

Migrate multiple feature flags properties between environments in a project. this includes: targets, rules, fallthrough, offVariation, prerequisites and optionally the flags on/off state.

Kind: instance method of LaunchDarklyUtilsFlags
Fulfil: Object updated feature flag json array
Reject: Error object with message

Param Type Description
projectKey string project identifier
featureFlagKeys string comma-separated feature flag identifiers
fromEnv string environment to copy flag attributes from
toEnv string environment to copy flag attributes to
includeState boolean optionally copy boolean state true/false

Example

ldutils bulkMigrateFeatureFlags my-project my-flag,my-flag-two dev test

launchDarklyUtilsFlags.restoreFeatureFlags(projectKey, featureFlagKeys, targetEnv, backupJsonFile, includeState) ⇒ Promise

Restore feature flags to state captured in a backup json file generated by getFeatureFlags(proj).

Kind: instance method of LaunchDarklyUtilsFlags
Fulfil: Object updated feature flag json
Reject: Error object with message

Param Type Description
projectKey string project identifier
featureFlagKeys string feature flag identifiers comma separated
targetEnv string environment to restore flag attributes to
backupJsonFile string file to restore from from getFeatureFlags(proj)
includeState boolean optionally restore boolean state true/false

Example

ldutils restoreFeatureFlags my-project my-flag,my-flag-two prod ./preReleaseBackup.json true

LaunchDarklyUtilsMembers

Kind: global class

new LaunchDarklyUtilsMembers(apiClient, log, ldUtils)

Team member specific api functions attached as 'LaunchDarklyUtils.members'

Returns: LaunchDarklyUtilsMembers - team member api functions

Param Type Description
apiClient Swagger generated launchdarkly apiClient
log Object logger implementation, or 'console'
ldUtils LaunchDarklyUtils primary utils class

launchDarklyUtilsMembers.API_GROUP ⇒ string

Api group object key in LD api

Kind: instance property of LaunchDarklyUtilsMembers

launchDarklyUtilsMembers.getTeamMembers(limit, offset, filter) ⇒ Promise

Get all team members in account

Kind: instance method of LaunchDarklyUtilsMembers
Fulfil: Object team member list json
Reject: Error object with message

Param Description
limit max number of members to return (defaults to 20 per api)
offset starting offset to return
filter an optional filter https://apidocs.launchdarkly.com/reference#list-team-members

Example

ldutils getTeamMembers

launchDarklyUtilsMembers.getTeamMember(memberId) ⇒ Promise

get a single team member by id

Kind: instance method of LaunchDarklyUtilsMembers
Fulfil: Object team member object json
Reject: Error object with message

Param Description
memberId _id field of team member

Example

ldutils getTeamMember 5a3ad672761af020881a8814

launchDarklyUtilsMembers.getTeamMemberByEmail(emailAddress) ⇒ Promise

Get a team member using a supplied email address

Kind: instance method of LaunchDarklyUtilsMembers
Fulfil: Object team member json
Reject: Error object with message

Param Type Description
emailAddress string email address of member to locate

Example

ldutils getTeamMemberByEmail owner-sample-account@launchdarkly.com

launchDarklyUtilsMembers.getTeamMemberCustomRoles(emailAddress) ⇒ Promise

Get a team member including customRoleKeys translated from customRoles array

Kind: instance method of LaunchDarklyUtilsMembers
Fulfil: Object team member json
Reject: Error object with message

Param Type Description
emailAddress string email address of member to locate

Example

ldutils getTeamMemberCustomRoles owner-sample-account@launchdarkly.com

launchDarklyUtilsMembers.inviteTeamMember(emailAddress, initialRoleKey) ⇒ Promise

Invite a New Team Member by their Email Address

Kind: instance method of LaunchDarklyUtilsMembers
Fulfil: Object Team Member JSON
Reject: Error object with message

Param Type Default Description
emailAddress String Email Address of New Member
initialRoleKey String reader Default Role for New Member

LaunchDarklyUtilsProjects

Kind: global class

new LaunchDarklyUtilsProjects(apiClient, log, ldUtils)

Projects specific api functions attached as 'LaunchDarklyUtils.projects'

Returns: LaunchDarklyUtilsMembers - team member api functions

Param Type Description
apiClient Swagger generated launchdarkly apiClient
log Object logger implementation, or 'console'
ldUtils LaunchDarklyUtils primary utils class

launchDarklyUtilsProjects.API_GROUP ⇒ string

Api group object key in LD api

Kind: instance property of LaunchDarklyUtilsProjects

launchDarklyUtilsProjects.getProjects() ⇒ Promise

Get all projects in account

Kind: instance method of LaunchDarklyUtilsProjects
Fulfil: Object List of projects JSON
Reject: Error object with message
Example

ldutils getProjects

launchDarklyUtilsProjects.getProject(projectKey) ⇒ Promise

get a single project by project key

Kind: instance method of LaunchDarklyUtilsProjects
Fulfil: Object project object json
Reject: Error object with message

Param Description
projectKey _id field of team member

Example

ldutils getProject new-project

launchDarklyUtilsProjects.createProject(projectName, projectKey, includeInSnippetByDefault, tags, environments, defaultClientSideAvailability) ⇒ Promise

Create a project in the account

Kind: instance method of LaunchDarklyUtilsProjects
Fulfil: Object project object json
Reject: Error object with message

Param Type Description
projectName * the name of the project
projectKey * the key that identifies the project
includeInSnippetByDefault * boolean true / false of whether should include a snippet
tags * arrays of tags that can be associated with the project
environments * an array of environments that are associated with the account
defaultClientSideAvailability * An object that defines wether the SDK and / or mobile flags are available

Example

ldutils createProject new-project 'New Project' 'false' dev,Development,#41705:test,Test,f5a623 'true' 'false' marketing,online

launchDarklyUtilsProjects.updateProject(projectKey, jsonPatch) ⇒ Promise

Patch a single project using jsonPatch notation

Kind: instance method of LaunchDarklyUtilsProjects
Fulfil: Object an empty project
Reject: Error object with message

Param Type Description
projectKey * projectKey a key that identifies the project
jsonPatch * an array of string using the JSON patch notation https://tools.ietf.org/html/rfc6902

Example

ldutils updateProject new-project [{ op: 'replace', path: '/name', value: 'New project name' }]

launchDarklyUtilsProjects.deleteProject(projectKey)

Delete a project

Kind: instance method of LaunchDarklyUtilsProjects
Fulfil: Object an empty project
Reject: Error object with message

Param Type Description
projectKey * projectKey a key that identifies the project

Example

ldutils deleteProject new-project

LaunchDarklyUtilsRoles

Kind: global class

new LaunchDarklyUtilsRoles(apiClient, log, ldUtils)

Custom role specific api functions attached as 'LaunchDarklyUtils.roles'

Returns: LaunchDarklyUtilsRoles - custom flag api functions

Param Type Description
apiClient Swagger generated launchdarkly apiClient
log Object logger implementation, or 'console'
ldUtils LaunchDarklyUtils primary utils class

launchDarklyUtilsRoles.API_GROUP ⇒ string

Api group object key in LD api

Kind: instance property of LaunchDarklyUtilsRoles

launchDarklyUtilsRoles.getCustomRoles() ⇒ Promise

Get all custom roles in account

Kind: instance method of LaunchDarklyUtilsRoles
Fulfil: Object custom role list json
Reject: Error object with message
Example

ldutils getTeamMemberCustomRoles owner-sample-account@launchdarkly.com

launchDarklyUtilsRoles.getCustomRole(customRoleKey) ⇒ Promise

Get a single custom role by key

Kind: instance method of LaunchDarklyUtilsRoles
Fulfil: Object custom role json
Reject: Error object with message

Param Type Description
customRoleKey string custom role key

Example

ldutils getCustomRole my-role

launchDarklyUtilsRoles.getCustomRoleById(customRoleId) ⇒ Promise

Get a single role by _id

Kind: instance method of LaunchDarklyUtilsRoles
Fulfil: Object custom role json
Reject: Error object with message

Param Type Description
customRoleId string custom role _id

Example

ldutils getCustomRoleById <id>

launchDarklyUtilsRoles.createCustomRole(customRoleKey, customRoleName, customRolePolicyArray, customRoleDescription) ⇒ Promise

Create a new custom role

Kind: instance method of LaunchDarklyUtilsRoles
Fulfil: Object custom role json
Reject: Error object with message

Param Type Description
customRoleKey string custom role key
customRoleName string custom role name
customRolePolicyArray string array of policy objects per https://docs.launchdarkly.com/docs/custom-roles
customRoleDescription string user friendly description

Example

ldutils createCustomRole my-role "My Role" [policyArrayJson] "some description"

launchDarklyUtilsRoles.updateCustomRole(customRoleKey, customRoleName, customRolePolicyArray, customRoleDescription) ⇒ Promise

Update an existing custom role

Kind: instance method of LaunchDarklyUtilsRoles
Fulfil: Object updated custom role json
Reject: Error object with message

Param Type Description
customRoleKey string custom role key
customRoleName string custom role name
customRolePolicyArray string array of policy objects per https://docs.launchdarkly.com/docs/custom-roles
customRoleDescription string user friendly description

Example

ldutils updateCustomRole my-role "My Role" [policyArrayJson] "some description"

launchDarklyUtilsRoles.upsertCustomRole(customRoleKey, customRoleName, customRolePolicyArray, customRoleDescription) ⇒ Promise

Check for existence of role by key; update if exists, otherwise create new role

Kind: instance method of LaunchDarklyUtilsRoles
Fulfil: Object updated/created custom role json
Reject: Error object with message

Param Type Description
customRoleKey string custom role key
customRoleName string custom role name
customRolePolicyArray string array of policy objects per https://docs.launchdarkly.com/docs/custom-roles
customRoleDescription string user friendly description

Example

ldutils upsertCustomRole my-role "My Role" [policyArrayJson] "some description"

launchDarklyUtilsRoles.bulkUpsertCustomRoles(roleBulkLoadFile) ⇒ Promise

Load a file of custom role json, and update/create roles based on this

Kind: instance method of LaunchDarklyUtilsRoles
Fulfil: Object array of updated/created role json
Reject: Error object with message

Param Type Description
roleBulkLoadFile string path to json file (eg. exampleRoleBulkLoad.json)

Example

ldutils bulkUpsertCustomRoles ./my-roles.json

launchDarklyUtilsRoles.bulkUpsertCustomRoleFolder(roleFolder) ⇒ Promise

Create/update custom roles based on a folder of multiple json files

Kind: instance method of LaunchDarklyUtilsRoles
Fulfil: Object array of updated/created role json
Reject: Error object with message

Param Type Description
roleFolder string path to folder containing json

Example

ldutils bulkUpsertCustomRoleFolder ./my-roles-dir-containing json