This is a Go client library to interact with the Unleash Admin API - in early development.
Requires unleash-server
v4.13 or higher.
- Features
- GetFeature
- CreateFeature
- UpdateFeature
- ArchiveFeature
- GetAllFeaturesByProject
- AddStrategyToFeature
- UpdateFeatureStrategy
- DeleteStrategyFromFeature
- EnableFeatureOnEnvironment
- GetAllFeatureTags
- CreateFeatureTags
- UpdateFeatureTags
- DeleteFeatureTags
- Strategies
- CreateStrategy
- UpdateStrategy
- DeprecateStrategy
- ReactivateStrategy
- GetAllStrategies
- GetStrategyByName
- Projects
- GetProjectById
- CreateProject
- UpdateProject
- DeleteProject
- Features v2
- AddUserProject
- UpdateUserProject
- DeleteUserProject
Import the package into your project:
import (
...
"github.com/philips-labs/go-unleash-api/api"
)
Create an API Client to your Unleash instance:
client, err := api.NewClient(&http.Client{}, "<unleash-instance-api-url>", "<unleash-api-token>")
Get all the tags of a feature toggle:
allFeatureTags, response, err := client.FeatureTags.GetAllFeatureTags("<your-toggle-id>")
if err != nil {
fmt.Printf("client: error making http request: %s\n", err)
body, err := ioutil.ReadAll(response.Request.Body)
if err != nil {
panic(err)
} else {
fmt.Print(body)
}
} else {
fmt.Print(allFeatureTags)
fmt.Print(response)
}
Create tags into a feature toggle:
createdFeatureTag, response, err := client.FeatureTags.CreateFeatureTags("<your-toggle-id>",
api.FeatureTag{
Type: "simple",
Value: "add-my-tag",
},
)
if err != nil {
fmt.Printf("client: error making http request: %s\n", err)
body, err := ioutil.ReadAll(response.Request.Body)
if err != nil {
panic(err)
} else {
fmt.Print(body)
}
} else {
fmt.Print(createdFeatureTag)
fmt.Print(response)
}
Update tags into a feature toggle:
updatedFeatureTag, response, err := client.FeatureTags.UpdateFeatureTags("teeste", []api.FeatureTag{}, []api.FeatureTag{
{
Type: "simple",
Value: "update-my-tag",
},
})
if err != nil {
fmt.Printf("client: error making http request: %s\n", err)
body, err := ioutil.ReadAll(response.Request.Body)
if err != nil {
panic(err)
} else {
fmt.Print(body)
}
} else {
fmt.Print(updatedFeatureTag)
fmt.Print(response)
}
Delete tags from a feature toggle:
response, err := client.FeatureTags.DeleteFeatureTags("teeste", api.FeatureTag{
Type: "simple",
Value: "feature2",
})
if err != nil {
fmt.Printf("client: error making http request: %s\n", err)
} else {
fmt.Print(response)
}