izanami

package module
v0.0.0-...-4133dc6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

README

izanami-go-client

Go client for izanami

Usage
c, errNew := New("host", "clientID", "clientSecret")
if errNew != nil {
	return errNew
}

// List all features
features, errF := c.Feature().ListAll()
if errF != nil {
	return errF
}

// Create a feature
f := FeatureModel{
	ID: "my-feature",
	Enabled: true,
	Strategy: NoStrategy,
}
if err := c.Feature().Create(f); err != nil {
	return err
}

// Get a feature
myFeature, errF := c.Feature().Get(f.ID)
if errF != nil {
	return errF
}

// Update a feature
if err := c.Feature().Update(myFeature); err != nil {
	return err
}

// Check a feature
check, err := c.Feature().CheckWithoutContext(feat.ID)
if err != nil {
	return err
}

// Delete a feature
if err := c.Feature().Delete(myFeature.ID); err != nil {
	return err
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivationStrategy

type ActivationStrategy string

ActivationStrategy represents the different way to activate a feature

const (
	NoStrategy   ActivationStrategy = "NO_STRATEGY"
	ReleaseDate  ActivationStrategy = "RELEASE_DATE"
	Script       ActivationStrategy = "SCRIPT"
	GlobalScript ActivationStrategy = "GLOBAL_SCRIPT"
)

type Client

type Client struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client represents the izanami client

func New

func New(apiURL, clientID, secret string) (*Client, error)

New creates a new izanami client

func (*Client) Feature

func (c *Client) Feature() *FeatureClient

Feature creates a specific client for feature management

func (*Client) Swagger

func (c *Client) Swagger() *SwaggerClient

Swagger creates a specific client for getting swagger.json

type FeatureCheckResponse

type FeatureCheckResponse struct {
	Active bool `json:"active"`
}

FeatureCheckResponse represents the hhtp response for a feature check

type FeatureClient

type FeatureClient struct {
	// contains filtered or unexported fields
}

FeatureClient represents a client for feature management

func (*FeatureClient) CheckWithContext

func (c *FeatureClient) CheckWithContext(id string, context interface{}) (FeatureCheckResponse, error)

CheckWithContext if a feature is enable for the given context

func (*FeatureClient) CheckWithoutContext

func (c *FeatureClient) CheckWithoutContext(id string) (FeatureCheckResponse, error)

CheckWithoutContext if a feature is enable

func (*FeatureClient) Create

func (c *FeatureClient) Create(feat FeatureModel) error

Create a new feature

func (*FeatureClient) Delete

func (c *FeatureClient) Delete(id string) error

Delete a feature by its id

func (*FeatureClient) Get

func (c *FeatureClient) Get(id string) (FeatureModel, error)

Get a feature by its id

func (*FeatureClient) List

func (c *FeatureClient) List(page int, pageSize int) (FeaturesResponse, error)

List features on the given page.

func (*FeatureClient) ListAll

func (c *FeatureClient) ListAll() ([]FeatureModel, error)

ListAll browses all pages and returns all features

func (*FeatureClient) Update

func (c *FeatureClient) Update(feat FeatureModel) error

Update the given feature

type FeatureModel

type FeatureModel struct {
	ID         string             `json:"id"`
	Enabled    bool               `json:"enabled"`
	Parameters map[string]string  `json:"parameters"`
	Strategy   ActivationStrategy `json:"activationStrategy"`
}

Feature represents a feature in izanami point of view

type FeaturesResponse

type FeaturesResponse struct {
	Results  []FeatureModel `json:"results"`
	Metadata Metadata       `json:"metadata"`
}

FeaturesResponse represents the http response for listAll

type Metadata

type Metadata struct {
	Page     int `json:"page"`
	PageSize int `json:"pageSize"`
	Count    int `json:"count"`
	NbPages  int `json:"nbPages"`
}

Metadata represents metadata parts of http response

type SwaggerClient

type SwaggerClient struct {
	// contains filtered or unexported fields
}

SwaggerClient represents a client for swagger endpoints

func (*SwaggerClient) Get

func (c *SwaggerClient) Get() (string, error)

Get swagger.json datas

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL