Skip to content

philips-labs/go-unleash-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-unleash-api

This is a Go client library to interact with the Unleash Admin API - in early development.

Requires unleash-server v4.13 or higher.

Impression data: FeatureToggle includes impressionData for create, read, and update via the Admin API. Unleash introduced this field in v4.7 (impression data).

Supported Endpoints

  • 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
  • Project Users
    • AddUserProject
    • UpdateUserProject
    • DeleteUserProject

How to use

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>")

Feature Toggle Tags service

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 := io.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 := io.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 := io.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)
}

About

Go client library to interact with the Unleash Admin API - in early development.

Resources

License

Contributing

Stars

1 star

Watchers

2 watching

Forks

Packages

 
 
 

Contributors

Languages