/api-client-go

Go client for the LaunchDarkly API

Primary LanguageGoOtherNOASSERTION

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

Go API client for ldapi

Build custom integrations with the LaunchDarkly REST API

Overview

This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you can easily generate an API client.

  • API version: 2.0.14
  • Package version: 1.0.0
  • Build package: io.swagger.codegen.languages.GoClientCodegen For more information, please visit https://support.launchdarkly.com

Installation

import "github.com/launchdarkly/api-client-go"

Documentation for API Endpoints

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

Class Method HTTP request Description
AuditLogApi GetAuditLogEntries 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 GetAuditLogEntry Get /auditlog/{resourceId} Use this endpoint to fetch a single audit log entry by its resouce ID.
CustomRolesApi DeleteCustomRole Delete /roles/{customRoleKey} Delete a custom role by key.
CustomRolesApi GetCustomRole Get /roles/{customRoleKey} Get one custom role by key.
CustomRolesApi GetCustomRoles Get /roles Return a complete list of custom roles.
CustomRolesApi PatchCustomRole Patch /roles/{customRoleKey} Modify a custom role by key.
CustomRolesApi PostCustomRole Post /roles Create a new custom role.
EnvironmentsApi DeleteEnvironment Delete /projects/{projectKey}/environments/{environmentKey} Delete an environment in a specific project.
EnvironmentsApi GetEnvironment Get /projects/{projectKey}/environments/{environmentKey} Get an environment given a project and key.
EnvironmentsApi PatchEnvironment Patch /projects/{projectKey}/environments/{environmentKey} Modify an environment by ID.
EnvironmentsApi PostEnvironment Post /projects/{projectKey}/environments Create a new environment in a specified project with a given name, key, and swatch color.
FeatureFlagsApi CopyFeatureFlag Post /flags/{projectKey}/{environmentKey}/{featureFlagKey}/copy Copies the feature flag configuration from one environment to the same feature flag in another environment.
FeatureFlagsApi DeleteFeatureFlag 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 GetFeatureFlag Get /flags/{projectKey}/{featureFlagKey} Get a single feature flag by key.
FeatureFlagsApi GetFeatureFlagStatus Get /flag-statuses/{projectKey}/{environmentKey}/{featureFlagKey} Get the status for a particular feature flag.
FeatureFlagsApi GetFeatureFlagStatuses 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 GetFeatureFlags Get /flags/{projectKey} Get a list of all features in the given project.
FeatureFlagsApi PatchFeatureFlag Patch /flags/{projectKey}/{featureFlagKey} Perform a partial update to a feature.
FeatureFlagsApi PostFeatureFlag Post /flags/{projectKey} Creates a new feature flag.
ProjectsApi DeleteProject 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 GetProject Get /projects/{projectKey} Fetch a single project by key.
ProjectsApi GetProjects Get /projects Returns a list of all projects in the account.
ProjectsApi PatchProject Patch /projects/{projectKey} Modify a project by ID.
ProjectsApi PostProject Post /projects Create a new project with the given key and name.
RootApi GetRoot Get /
TeamMembersApi DeleteMember Delete /members/{memberId} Delete a team member by ID.
TeamMembersApi GetMember Get /members/{memberId} Get a single team member by ID.
TeamMembersApi GetMembers Get /members Returns a list of all members in the account.
TeamMembersApi PatchMember Patch /members/{memberId} Modify a team member by ID.
TeamMembersApi PostMembers Post /members Invite new members.
UserSegmentsApi DeleteUserSegment Delete /segments/{projectKey}/{environmentKey}/{userSegmentKey} Delete a user segment.
UserSegmentsApi GetUserSegment Get /segments/{projectKey}/{environmentKey}/{userSegmentKey} Get a single user segment by key.
UserSegmentsApi GetUserSegments Get /segments/{projectKey}/{environmentKey} Get a list of all user segments in the given project.
UserSegmentsApi PatchUserSegment Patch /segments/{projectKey}/{environmentKey}/{userSegmentKey} Perform a partial update to a user segment.
UserSegmentsApi PostUserSegment Post /segments/{projectKey}/{environmentKey} Creates a new user segment.
UserSettingsApi GetUserFlagSetting Get /users/{projectKey}/{environmentKey}/{userKey}/flags/{featureFlagKey} Fetch a single flag setting for a user by key.
UserSettingsApi GetUserFlagSettings Get /users/{projectKey}/{environmentKey}/{userKey}/flags Fetch a single flag setting for a user by key.
UserSettingsApi PutFlagSetting Put /users/{projectKey}/{environmentKey}/{userKey}/flags/{featureFlagKey} Specifically enable or disable a feature flag for a user based on their key.
UsersApi DeleteUser Delete /users/{projectKey}/{environmentKey}/{userKey} Delete a user by ID.
UsersApi GetSearchUsers 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 GetUser Get /users/{projectKey}/{environmentKey}/{userKey} Get a user by key.
UsersApi GetUsers 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 DeleteWebhook Delete /webhooks/{resourceId} Delete a webhook by ID.
WebhooksApi GetWebhook Get /webhooks/{resourceId} Get a webhook by ID.
WebhooksApi GetWebhooks Get /webhooks Fetch a list of all webhooks.
WebhooksApi PatchWebhook Patch /webhooks/{resourceId} Modify a webhook by ID.
WebhooksApi PostWebhook Post /webhooks Create a webhook.

Documentation For Models

Author

support@launchdarkly.com

Sample Code

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/launchdarkly/api-client-go"
)

func main() {
	apiKey := os.Getenv("LD_API_KEY")
	if apiKey == "" {
		panic("LD_API_KEY env var was empty!")
	}
	client := ldapi.NewAPIClient(ldapi.NewConfiguration())
	ctx := context.WithValue(context.Background(), ldapi.ContextAPIKey, ldapi.APIKey{
		Key: apiKey,
	})

	// Create a multi-variate feature flag
	body := ldapi.FeatureFlagBody{
		Name: "Test Flag Go",
		Key:  "test-go",
		Variations: []ldapi.Variation{
			{Value: intfPtr([]interface{}{1, 2})},
			{Value: intfPtr([]interface{}{3, 4})},
			{Value: intfPtr([]interface{}{5})}}}
	flag, _, err := client.FeatureFlagsApi.PostFeatureFlag(ctx, "openapi", body, nil)
	if err != nil {
		panic(fmt.Errorf("create failed: %s", err))
	}
	fmt.Printf("Created flag: %+v\n", flag)
	// Clean up new flag
	defer func() {
		if _, err := client.FeatureFlagsApi.DeleteFeatureFlag(ctx, "openapi", body.Key); err != nil {
			panic(fmt.Errorf("delete failed: %s", err))
		}
	}()
}

func intfPtr(i interface{}) *interface{} {
	return &i
}