api

package
v0.0.0-...-8fa20a7 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 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

func ErrRequiredParam(param string) error

Types

type AddUserRoleResponse

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

type AllApiTokensResponse

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

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

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

func (*ApiTokenService) CreateApiToken

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

func (*ApiTokenService) DeleteApiToken

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

func (*ApiTokenService) GetAllApiTokens

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

func (*ApiTokenService) UpdateApiToken

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

type CreateProjectResponse

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

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 []string    `json:"constraints,omitempty"`
	Parameters  interface{} `json:"parameters,omitempty"`
	SortOrder   int         `json:"sortOrder"`
}

type FeatureTag

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

type FeatureTagsResponse

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

type FeatureTagsService

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

func (*FeatureTagsService) CreateFeatureTags

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

func (*FeatureTagsService) DeleteFeatureTags

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

func (*FeatureTagsService) GetAllFeatureTags

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

func (*FeatureTagsService) UpdateFeatureTags

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

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

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

type Project

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

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

func (*ProjectsService) CreateProject

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

func (*ProjectsService) DeleteProject

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

func (*ProjectsService) DeleteUserProject

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

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

func (*ProjectsService) UpdateUserProject

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 StrategyParameter

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

type UpdateFeatureTagsBody

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

type User

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

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

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

func (*UsersService) CreateUser

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

func (*UsersService) DeleteUser

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

func (*UsersService) GetUserById

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

func (*UsersService) SearchUser

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

func (*UsersService) UpdateUser

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

type Variant

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

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

type VariantPayload

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

type VariantsResponse

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

type VariantsService

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

func (*VariantsService) AddVariantsForFeatureToggle

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