api

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LibraryVersion = "0.0.1"
)

Variables

View Source
var (
	ErrNotFound               = errors.New("entity not found")
	ErrApiUrlCannotBeEmpty    = errors.New("api_url cannot be empty")
	ErrTokenAuthCannotBeEmpty = errors.New("auth_token cannot be empty")
)

Exported Errors

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present.

func ErrRequiredParam added in v0.1.1

func ErrRequiredParam(param string) error

Types

type AddUserRoleResponse added in v1.0.3

type AddUserRoleResponse struct {
	UserId    int    `json:"userId"`
	ProjectId string `json:"projectId"`
	RoleId    int    `json:"roleId"`
}

type AllApiTokensResponse added in v1.0.2

type AllApiTokensResponse struct {
	Tokens []ApiToken `json:"tokens"`
}

type AllFeatureTypesResponse

type AllFeatureTypesResponse struct {
	Version int           `json:"version"`
	Types   []FeatureType `json:"types"`
}

type AllStrategiesResponse

type AllStrategiesResponse struct {
	Version    int        `json:"version"`
	Strategies []Strategy `json:"strategies"`
}

type ApiClient

type ApiClient struct {
	UserAgent string

	FeatureTags    *FeatureTagsService
	FeatureToggles *FeatureTogglesService
	Projects       *ProjectsService
	FeatureTypes   *FeatureTypesService
	Strategies     *StrategiesService
	Variants       *VariantsService
	Users          *UsersService
	ApiTokens      *ApiTokenService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient HTTPClient, apiUrl string, authToken string) (*ApiClient, error)

type ApiToken added in v1.0.2

type ApiToken struct {
	Secret      string   `json:"secret,omitempty"`
	Username    string   `json:"username"`
	Type        string   `json:"type"`
	Environment string   `json:"environment,omitempty"`
	Projects    []string `json:"projects,omitempty"`
	ExpiresAt   string   `json:"expiresAt,omitempty"`
	CreatedAt   string   `json:"createdAt,omitempty"`
}

type ApiTokenService added in v1.0.2

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

func (*ApiTokenService) CreateApiToken added in v1.0.2

func (p *ApiTokenService) CreateApiToken(token ApiToken) (*ApiToken, *Response, error)

func (*ApiTokenService) DeleteApiToken added in v1.0.2

func (p *ApiTokenService) DeleteApiToken(secret string) (bool, *Response, error)

func (*ApiTokenService) GetAllApiTokens added in v1.0.2

func (p *ApiTokenService) GetAllApiTokens() (*AllApiTokensResponse, *Response, error)

func (*ApiTokenService) UpdateApiToken added in v1.0.2

func (p *ApiTokenService) UpdateApiToken(secret string, token ApiToken) (bool, *Response, error)

type CreateProjectResponse added in v1.0.3

type CreateProjectResponse struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	CreatedAt   string `json:"createdAt"`
}

type Environment

type Environment struct {
	Enabled    bool              `json:"enabled"`
	Name       string            `json:"name"`
	Type       string            `json:"type"`
	Strategies []FeatureStrategy `json:"strategies"`
}

type ErrorResponse added in v1.0.3

type ErrorResponse struct {
	Error struct {
		Name    string `json:"name"`
		Message string `json:"message"`
	} `json:"error"`
}

type FeatureStrategy

type FeatureStrategy struct {
	ID          string               `json:"id,omitempty"`
	Name        string               `json:"name"`
	Constraints []StrategyConstraint `json:"constraints,omitempty"`
	Parameters  interface{}          `json:"parameters,omitempty"`
	SortOrder   int                  `json:"sortOrder"`
}

type FeatureTag added in v1.0.4

type FeatureTag struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type FeatureTagsResponse added in v1.0.4

type FeatureTagsResponse struct {
	Version int          `json:"version"`
	Tags    []FeatureTag `json:"tags"`
}

type FeatureTagsService added in v1.0.4

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

func (*FeatureTagsService) CreateFeatureTags added in v1.0.4

func (p *FeatureTagsService) CreateFeatureTags(featureName string, tag FeatureTag) (*FeatureTag, *Response, error)

func (*FeatureTagsService) DeleteFeatureTags added in v1.0.4

func (p *FeatureTagsService) DeleteFeatureTags(featureName string, tag FeatureTag) (*Response, error)

func (*FeatureTagsService) GetAllFeatureTags added in v1.0.4

func (p *FeatureTagsService) GetAllFeatureTags(featureName string) (*FeatureTagsResponse, *Response, error)

func (*FeatureTagsService) UpdateFeatureTags added in v1.0.4

func (p *FeatureTagsService) UpdateFeatureTags(featureName string, addedTags []FeatureTag, removedTags []FeatureTag) (*FeatureTagsResponse, *Response, error)

type FeatureToggle

type FeatureToggle struct {
	Archived     bool          `json:"archived"`
	CreatedAt    string        `json:"createdAt,omitempty"`
	LastSeenAt   string        `json:"lastSeenAt,omitempty"`
	Description  string        `json:"description"`
	Name         string        `json:"name"`
	Project      string        `json:"project"`
	Stale        bool          `json:"stale"`
	Type         string        `json:"type"`
	Environments []Environment `json:"environments"`
	Variants     []Variant     `json:"variants"`
}

type FeatureTogglesService

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

func (*FeatureTogglesService) AddStrategyToFeature

func (p *FeatureTogglesService) AddStrategyToFeature(projectId string, featureName string, environment string, featureStrategy FeatureStrategy) (*FeatureStrategy, *Response, error)

Adds a strategy to a feature toggle in a given environment

func (*FeatureTogglesService) ArchiveFeature

func (p *FeatureTogglesService) ArchiveFeature(projectId string, featureName string) (bool, *Response, error)

func (*FeatureTogglesService) CreateFeature

func (p *FeatureTogglesService) CreateFeature(projectId string, feature FeatureToggle) (*FeatureToggle, *Response, error)

func (*FeatureTogglesService) DeleteArchivedFeature added in v0.1.0

func (p *FeatureTogglesService) DeleteArchivedFeature(featureName string) (bool, *Response, error)

func (*FeatureTogglesService) DeleteStrategyFromFeature

func (p *FeatureTogglesService) DeleteStrategyFromFeature(projectId string, featureName string, environment string, strategyId string) (bool, *Response, error)

Deletes a strategy from a feature toggle in a given environment

func (*FeatureTogglesService) DeprecateStrategy

func (p *FeatureTogglesService) DeprecateStrategy(strategyName string) (bool, *Response, error)

func (*FeatureTogglesService) EnableFeatureOnEnvironment

func (p *FeatureTogglesService) EnableFeatureOnEnvironment(projectId string, featureName string, environment string, enabled bool) (bool, *Response, error)

func (*FeatureTogglesService) GetFeatureByName

func (p *FeatureTogglesService) GetFeatureByName(projectId string, featureName string) (*FeatureToggle, *Response, error)

func (*FeatureTogglesService) GetFeaturesByProject

func (p *FeatureTogglesService) GetFeaturesByProject(projectId string) (*[]FeatureToggle, *Response, error)

func (*FeatureTogglesService) ReactivateStrategy

func (p *FeatureTogglesService) ReactivateStrategy(strategyName string) (bool, *Response, error)

func (*FeatureTogglesService) UpdateFeature

func (p *FeatureTogglesService) UpdateFeature(projectId string, feature FeatureToggle) (*FeatureToggle, *Response, error)

func (*FeatureTogglesService) UpdateFeatureStrategy

func (p *FeatureTogglesService) UpdateFeatureStrategy(projectId string, featureName string, environment string, featureStrategy FeatureStrategy) (*FeatureStrategy, *Response, error)

type FeatureType

type FeatureType struct {
	ID           string `json:"id,omitempty"`
	Name         string `json:"name"`
	Description  string `json:"description"`
	LifetimeDays int    `json:"lifetimeDays"`
}

type FeatureTypesService

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

func (*FeatureTypesService) GetAllFeatureTypes

func (p *FeatureTypesService) GetAllFeatureTypes() (*AllFeatureTypesResponse, *Response, error)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient interface

type ProjEnvironment added in v1.0.6

type ProjEnvironment struct {
	Environment string `json:"environment"`
}

type Project added in v1.0.3

type Project struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type ProjectDetails

type ProjectDetails struct {
	Name         string            `json:"name"`
	Description  string            `json:"description"`
	Health       int               `json:"health"`
	UpdatedAt    string            `json:"updatedAt"`
	Environments []ProjEnvironment `json:"environments"`
}

type ProjectsService

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

func (*ProjectsService) AddUserProject added in v1.0.3

func (p *ProjectsService) AddUserProject(userId int, projectId string, roleId int) (*AddUserRoleResponse, *Response, error)

func (*ProjectsService) CreateProject added in v1.0.3

func (p *ProjectsService) CreateProject(project Project) (*CreateProjectResponse, *Response, error)

func (*ProjectsService) DeleteProject added in v1.0.3

func (p *ProjectsService) DeleteProject(projectId string) (*Response, error)

func (*ProjectsService) DeleteUserProject added in v1.0.3

func (p *ProjectsService) DeleteUserProject(projectId string, userId int, roleId int) (*AddUserRoleResponse, *Response, error)

func (*ProjectsService) GetProjectById

func (p *ProjectsService) GetProjectById(projectId string) (*ProjectDetails, *Response, error)

func (*ProjectsService) UpdateProject added in v1.0.3

func (p *ProjectsService) UpdateProject(projectId string, project Project) (*CreateProjectResponse, *Response, error)

func (*ProjectsService) UpdateUserProject added in v1.0.3

func (p *ProjectsService) UpdateUserProject(projectId string, userId int, roleId int) (*AddUserRoleResponse, *Response, error)

type Response

type Response struct {
	*http.Response
}

type StrategiesService

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

func (*StrategiesService) CreateStrategy

func (p *StrategiesService) CreateStrategy(strategy Strategy) (*Strategy, *Response, error)

func (*StrategiesService) GetAllStrategies

func (p *StrategiesService) GetAllStrategies() (*AllStrategiesResponse, *Response, error)

func (*StrategiesService) GetStrategyByName

func (p *StrategiesService) GetStrategyByName(strategyName string) (*Strategy, *Response, error)

func (*StrategiesService) UpdateStrategy

func (p *StrategiesService) UpdateStrategy(strategy Strategy) (*Strategy, *Response, error)

type Strategy

type Strategy struct {
	ID          string              `json:"id,omitempty"`
	Name        string              `json:"name"`
	DisplayName string              `json:"displayName,omitempty"`
	Description string              `json:"description"`
	Editable    bool                `json:"editable"`
	Deprecated  bool                `json:"deprecated"`
	Parameters  []StrategyParameter `json:"parameters"`
}

FeatureToggle represents a Feature Toggle resource

type StrategyConstraint added in v1.0.7

type StrategyConstraint struct {
	ContextName     string   `json:"contextName"`
	Operator        string   `json:"operator"`
	Value           string   `json:"value"`
	Values          []string `json:"values"`
	Inverted        bool     `json:"inverted"`
	CaseInsensitive bool     `json:"caseInsensitive"`
}

type StrategyParameter

type StrategyParameter struct {
	Description string `json:"description"`
	Name        string `json:"name"`
	Required    bool   `json:"required"`
	Type        string `json:"type"`
}

type UpdateFeatureTagsBody added in v1.0.4

type UpdateFeatureTagsBody struct {
	AddedTags   []FeatureTag `json:"addedTags"`
	RemovedTags []FeatureTag `json:"removedTags"`
}

type User added in v0.1.1

type User struct {
	Name      string `json:"name"`
	Username  string `json:"username"`
	Email     string `json:"email"`
	RootRole  int    `json:"rootRole"`
	SendEmail bool   `json:"sendEmail"`
}

type UserDetails added in v0.1.1

type UserDetails struct {
	Id         int    `json:"id"`
	Name       string `json:"name,omitempty"`
	Username   string `json:"username,omitempty"`
	Email      string `json:"email,omitempty"`
	ImageUrl   string `json:"imageUrl,omitempty"`
	CreatedAt  string `json:"createdAt,omitempty"`
	InviteLink string `json:"inviteLink,omitempty"`
	EmailSent  bool   `json:"emailSent,omitempty"`
	RootRole   int    `json:"rootRole,omitempty"`
}

type UsersService added in v0.1.1

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

func (*UsersService) CreateUser added in v0.1.1

func (p *UsersService) CreateUser(user User) (*UserDetails, *Response, error)

func (*UsersService) DeleteUser added in v0.1.1

func (p *UsersService) DeleteUser(userId string) (bool, *Response, error)

func (*UsersService) GetUserById added in v0.1.1

func (p *UsersService) GetUserById(userId string) (*UserDetails, *Response, error)

func (*UsersService) SearchUser added in v0.1.1

func (p *UsersService) SearchUser(query string) (*[]UserDetails, *Response, error)

func (*UsersService) UpdateUser added in v0.1.1

func (p *UsersService) UpdateUser(userId string, user User) (*UserDetails, *Response, error)

type Variant added in v0.0.3

type Variant struct {
	Name       string            `json:"name"`
	Stickiness string            `json:"stickiness"`
	Weight     int               `json:"weight"`
	WeightType string            `json:"weightType"`
	Overrides  []VariantOverride `json:"overrides,omitempty"`
	Payload    *VariantPayload   `json:"payload,omitempty"`
}

type VariantOverride added in v0.0.3

type VariantOverride struct {
	ContextName string   `json:"contextName"`
	Values      []string `json:"values"`
}

type VariantPayload added in v0.0.3

type VariantPayload struct {
	Type  string `json:"type,omitempty"`
	Value string `json:"value,omitempty"`
}

type VariantsResponse added in v0.0.5

type VariantsResponse struct {
	Version  int       `json:"version"`
	Variants []Variant `json:"variants"`
}

type VariantsService added in v0.0.5

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

func (*VariantsService) AddVariantsForFeatureToggle added in v0.0.5

func (p *VariantsService) AddVariantsForFeatureToggle(projectId string, featureName string, variants []Variant) (*VariantsResponse, *Response, error)

Jump to

Keyboard shortcuts

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