Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) AddFeatureGroupOwners(feature *Feature, groupIDs []int64) error
- func (c *Client) AddFeatureOwners(feature *Feature, ownerIDs []int64) error
- func (c *Client) BuildMetadata(projectID int64, entity MetadataEntity, values map[string]string) (*[]Metadata, error)
- func (c *Client) CreateEnvironment(environment *Environment) error
- func (c *Client) CreateFeature(feature *Feature) error
- func (c *Client) CreateFeatureMVOption(featureMVOption *FeatureMultivariateOption) error
- func (c *Client) CreateFeatureSegment(featureSegment *FeatureSegment) error
- func (c *Client) CreateIdentity(environmentKey string, identity *Identity) error
- func (c *Client) CreateProject(project *Project) error
- func (c *Client) CreateSegment(segment *Segment) error
- func (c *Client) CreateSegmentOverride(featureState *FeatureState) error
- func (c *Client) CreateServerSideEnvKey(environmentKey string, key *ServerSideEnvKey) error
- func (c *Client) CreateTag(tag *Tag) error
- func (c *Client) CreateTrait(environmentKey string, identityID int64, trait *Trait) error
- func (c *Client) DeleteEnvironment(apiKey string) error
- func (c *Client) DeleteFeature(projectID, featureID int64) error
- func (c *Client) DeleteFeatureMVOption(projectID, featureID, mvOptionID int64) error
- func (c *Client) DeleteFeatureSegment(featureSegmentID int64) error
- func (c *Client) DeleteIdentity(environmentKey string, identityID int64) error
- func (c *Client) DeleteProject(projectID int64) error
- func (c *Client) DeleteSegment(projectID, segmentID int64) error
- func (c *Client) DeleteServerSideEnvKey(environmentKey string, keyID int64) error
- func (c *Client) DeleteTag(projectID, tagID int64) error
- func (c *Client) DeleteTrait(environmentKey string, identityID int64, traitID int64) error
- func (c *Client) GetEnvironment(apiKey string) (*Environment, error)
- func (c *Client) GetEnvironmentByUUID(uuid string) (*Environment, error)
- func (c *Client) GetEnvironmentFeatureState(environmentKey string, featureID int64) (*FeatureState, error)
- func (c *Client) GetFeature(featureUUID string) (*Feature, error)
- func (c *Client) GetFeatureMVOption(featureUUID, mvOptionUUID string) (*FeatureMultivariateOption, error)
- func (c *Client) GetFeatureSegmentByID(featureSegmentID int64) (*FeatureSegment, error)
- func (c *Client) GetFeatureState(featureStateUUID string) (*FeatureState, error)
- func (c *Client) GetIdentity(environmentKey string, identityID int64) (*Identity, error)
- func (c *Client) GetMetadataFieldResolver(projectID int64, entity MetadataEntity) (*MetadataFieldResolver, error)
- func (c *Client) GetOrganisationByUUID(orgUUID string) (*Organisation, error)
- func (c *Client) GetOrganisationUserByEmail(orgID int64, email string) (*User, error)
- func (c *Client) GetOrganisationUsers(orgID int64) ([]User, error)
- func (c *Client) GetProject(projectUUID string) (*Project, error)
- func (c *Client) GetProjectByID(projectID int64) (*Project, error)
- func (c *Client) GetProjectMetadataFields(projectID int64) ([]MetadataField, error)
- func (c *Client) GetSegment(segmentUUID string) (*Segment, error)
- func (c *Client) GetServerSideEnvKeys(environmentKey string) ([]ServerSideEnvKey, error)
- func (c *Client) GetSupportedMetadataContentTypes(organisationID int64) ([]ContentTypeInfo, error)
- func (c *Client) GetTag(projectUUID string, tagUUID string) (*Tag, error)
- func (c *Client) GetTraits(environmentKey string, identityID int64) ([]Trait, error)
- func (c *Client) RemoveFeatureGroupOwners(feature *Feature, groupIDs []int64) error
- func (c *Client) RemoveFeatureOwners(feature *Feature, ownerIDs []int64) error
- func (c *Client) ResolveMetadataNames(projectID int64, entity MetadataEntity, metadata []Metadata) (map[string]string, []int64, error)
- func (c *Client) UpdateEnvironment(environment *Environment) error
- func (c *Client) UpdateFeature(feature *Feature) error
- func (c *Client) UpdateFeatureMVOption(featureMVOption *FeatureMultivariateOption) error
- func (c *Client) UpdateFeatureSegmentPriority(featureSegmentID, priority int64) error
- func (c *Client) UpdateFeatureState(featureState *FeatureState, updateSegmentPriority bool) error
- func (c *Client) UpdateProject(project *Project) error
- func (c *Client) UpdateSegment(segment *Segment) error
- func (c *Client) UpdateServerSideEnvKey(environmentKey string, key *ServerSideEnvKey) error
- func (c *Client) UpdateTag(tag *Tag) error
- func (c *Client) UpdateTrait(environmentKey string, identityID int64, trait *Trait) error
- type Condition
- type ContentTypeInfo
- type Environment
- type Feature
- type FeatureMVOptionNotFoundError
- type FeatureMultivariateOption
- type FeatureNotFoundError
- type FeatureSegment
- type FeatureState
- type FeatureStateNotFoundError
- type FeatureStateValue
- type Identity
- type Metadata
- type MetadataEntity
- type MetadataField
- type MetadataFieldInvalidValueError
- type MetadataFieldNotBoundError
- type MetadataFieldNotFoundError
- type MetadataFieldResolver
- type MetadataModelField
- type Organisation
- type Project
- type Rule
- type Segment
- type SegmentNotFoundError
- type ServerSideEnvKey
- type Tag
- type Trait
- type User
- type UserNotFoundError
Constants ¶
const BaseAPIURL = "https://api.flagsmith.com/api/v1"
const MetadataFieldValueMaxLength = 2000
MetadataFieldValueMaxLength mirrors FIELD_VALUE_MAX_LENGTH in api/metadata/models.py.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AddFeatureGroupOwners ¶ added in v0.11.0
func (*Client) AddFeatureOwners ¶ added in v0.5.0
func (*Client) BuildMetadata ¶ added in v0.12.0
func (c *Client) BuildMetadata(projectID int64, entity MetadataEntity, values map[string]string) (*[]Metadata, error)
BuildMetadata converts a map of custom field names to values into the wire format, validating each value against its field's configured type.
A nil or empty map yields a non-nil empty slice, which serialises as `"metadata": []`, i.e. an explicit "this entity has no custom field values".
func (*Client) CreateEnvironment ¶ added in v0.9.0
func (c *Client) CreateEnvironment(environment *Environment) error
func (*Client) CreateFeature ¶ added in v0.1.0
func (*Client) CreateFeatureMVOption ¶ added in v0.2.0
func (c *Client) CreateFeatureMVOption(featureMVOption *FeatureMultivariateOption) error
func (*Client) CreateFeatureSegment ¶ added in v0.4.0
func (c *Client) CreateFeatureSegment(featureSegment *FeatureSegment) error
func (*Client) CreateIdentity ¶ added in v0.9.0
func (*Client) CreateProject ¶ added in v0.9.0
func (*Client) CreateSegment ¶ added in v0.3.0
func (*Client) CreateSegmentOverride ¶ added in v0.4.0
func (c *Client) CreateSegmentOverride(featureState *FeatureState) error
func (*Client) CreateServerSideEnvKey ¶ added in v0.9.0
func (c *Client) CreateServerSideEnvKey(environmentKey string, key *ServerSideEnvKey) error
func (*Client) CreateTrait ¶ added in v0.9.0
func (*Client) DeleteEnvironment ¶ added in v0.9.0
func (*Client) DeleteFeature ¶ added in v0.1.0
func (*Client) DeleteFeatureMVOption ¶ added in v0.2.0
func (*Client) DeleteFeatureSegment ¶ added in v0.4.0
func (*Client) DeleteIdentity ¶ added in v0.9.0
func (*Client) DeleteProject ¶ added in v0.9.0
func (*Client) DeleteSegment ¶ added in v0.3.0
func (*Client) DeleteServerSideEnvKey ¶ added in v0.9.0
func (*Client) DeleteTrait ¶ added in v0.9.0
func (*Client) GetEnvironment ¶ added in v0.4.0
func (c *Client) GetEnvironment(apiKey string) (*Environment, error)
func (*Client) GetEnvironmentByUUID ¶ added in v0.10.0
func (c *Client) GetEnvironmentByUUID(uuid string) (*Environment, error)
func (*Client) GetEnvironmentFeatureState ¶
func (c *Client) GetEnvironmentFeatureState(environmentKey string, featureID int64) (*FeatureState, error)
Get the feature state associated with the environment for a given feature
func (*Client) GetFeature ¶ added in v0.1.0
func (*Client) GetFeatureMVOption ¶ added in v0.2.0
func (c *Client) GetFeatureMVOption(featureUUID, mvOptionUUID string) (*FeatureMultivariateOption, error)
func (*Client) GetFeatureSegmentByID ¶ added in v0.4.0
func (c *Client) GetFeatureSegmentByID(featureSegmentID int64) (*FeatureSegment, error)
func (*Client) GetFeatureState ¶ added in v0.4.0
func (c *Client) GetFeatureState(featureStateUUID string) (*FeatureState, error)
func (*Client) GetIdentity ¶ added in v0.9.0
func (*Client) GetMetadataFieldResolver ¶ added in v0.12.0
func (c *Client) GetMetadataFieldResolver(projectID int64, entity MetadataEntity) (*MetadataFieldResolver, error)
GetMetadataFieldResolver returns a resolver for the given project and entity.
Building one costs three requests: the project, its organisation's content types, and the project's custom field definitions. The result is cached for the lifetime of the client, so a caller writing many entities in one project pays that once. A field created after the first call for a project will not be seen.
func (*Client) GetOrganisationByUUID ¶ added in v0.10.0
func (c *Client) GetOrganisationByUUID(orgUUID string) (*Organisation, error)
func (*Client) GetOrganisationUserByEmail ¶ added in v0.11.0
func (*Client) GetOrganisationUsers ¶ added in v0.11.0
func (*Client) GetProject ¶ added in v0.1.0
func (*Client) GetProjectByID ¶ added in v0.1.0
func (*Client) GetProjectMetadataFields ¶ added in v0.12.0
func (c *Client) GetProjectMetadataFields(projectID int64) ([]MetadataField, error)
GetProjectMetadataFields returns every custom field definition visible to a project: the project's own fields plus the inherited organisation level fields.
NOTE: the endpoint's `entity` query param is deliberately not used. It filters which *fields* are returned but does NOT filter each field's nested `model_fields`, so callers have to match on content type regardless. Fetching everything lets a single response serve all three entity types and produce precise "this field exists but is not enabled for features" errors.
func (*Client) GetSegment ¶ added in v0.3.0
func (*Client) GetServerSideEnvKeys ¶ added in v0.9.0
func (c *Client) GetServerSideEnvKeys(environmentKey string) ([]ServerSideEnvKey, error)
func (*Client) GetSupportedMetadataContentTypes ¶ added in v0.12.0
func (c *Client) GetSupportedMetadataContentTypes(organisationID int64) ([]ContentTypeInfo, error)
func (*Client) RemoveFeatureGroupOwners ¶ added in v0.11.0
func (*Client) RemoveFeatureOwners ¶ added in v0.5.0
func (*Client) ResolveMetadataNames ¶ added in v0.12.0
func (c *Client) ResolveMetadataNames(projectID int64, entity MetadataEntity, metadata []Metadata) (map[string]string, []int64, error)
ResolveMetadataNames converts wire format metadata back into a map of custom field names to values.
Model field IDs the resolver does not recognise are skipped and returned in unresolved, so that a deleted custom field cannot make a read fail.
func (*Client) UpdateEnvironment ¶ added in v0.9.0
func (c *Client) UpdateEnvironment(environment *Environment) error
func (*Client) UpdateFeature ¶ added in v0.1.0
func (*Client) UpdateFeatureMVOption ¶ added in v0.2.0
func (c *Client) UpdateFeatureMVOption(featureMVOption *FeatureMultivariateOption) error
func (*Client) UpdateFeatureSegmentPriority ¶ added in v0.4.0
func (*Client) UpdateFeatureState ¶
func (c *Client) UpdateFeatureState(featureState *FeatureState, updateSegmentPriority bool) error
Update the feature state
func (*Client) UpdateProject ¶ added in v0.9.0
func (*Client) UpdateSegment ¶ added in v0.3.0
func (*Client) UpdateServerSideEnvKey ¶ added in v0.9.0
func (c *Client) UpdateServerSideEnvKey(environmentKey string, key *ServerSideEnvKey) error
type ContentTypeInfo ¶ added in v0.12.0
type ContentTypeInfo struct {
ID int64 `json:"id"`
AppLabel string `json:"app_label"`
Model string `json:"model"`
}
ContentTypeInfo identifies a Django content type. IDs are specific to a Flagsmith installation and must never be hardcoded.
type Environment ¶ added in v0.4.0
type Environment struct {
ID int64 `json:"id,omitempty"`
UUID string `json:"uuid,omitempty"`
Name string `json:"name"`
APIKey string `json:"api_key,omitempty"`
Description string `json:"description"`
ProjectID int64 `json:"project"`
AllowClientTraits bool `json:"allow_client_traits,omitempty"`
BannerText string `json:"banner_text,omitempty"`
BannerColour string `json:"banner_colour,omitempty"`
HideDisabledFlags bool `json:"hide_disabled_flags,omitempty"`
HideSensitiveData bool `json:"hide_sensitive_data,omitempty"`
UseIdentityCompositeKeyForHashing bool `json:"use_identity_composite_key_for_hashing,omitempty"`
MinimumChangeRequestApprovals int64 `json:"minimum_change_request_approvals,omitempty"`
Metadata *[]Metadata `json:"metadata,omitempty"`
}
type Feature ¶ added in v0.1.0
type Feature struct {
Name string `json:"name"`
UUID string `json:"uuid,omitempty"`
ID *int64 `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Description *string `json:"description,omitempty"`
InitialValue string `json:"initial_value,omitempty"`
DefaultEnabled bool `json:"default_enabled,omitempty"`
IsArchived bool `json:"is_archived,omitempty"`
Owners *[]int64 `json:"owners,omitempty"`
GroupOwners *[]int64 `json:"group_owners,omitempty"`
Tags []int64 `json:"tags"`
Metadata *[]Metadata `json:"metadata,omitempty"`
ProjectUUID string `json:"-"`
ProjectID *int64 `json:"project,omitempty"`
}
func (*Feature) UnmarshalJSON ¶ added in v0.5.0
type FeatureMVOptionNotFoundError ¶ added in v0.6.0
type FeatureMVOptionNotFoundError struct {
// contains filtered or unexported fields
}
func (FeatureMVOptionNotFoundError) Error ¶ added in v0.6.0
func (e FeatureMVOptionNotFoundError) Error() string
type FeatureMultivariateOption ¶ added in v0.2.0
type FeatureMultivariateOption struct {
ID int64 `json:"id,omitempty"`
Type string `json:"type"`
UUID string `json:"uuid,omitempty"`
FeatureID *int64 `json:"feature,omitempty"`
IntegerValue *int64 `json:"integer_value,omitempty"`
StringValue *string `json:"string_value,omitempty"`
BooleanValue *bool `json:"boolean_value,omitempty"`
DefaultPercentageAllocation float64 `json:"default_percentage_allocation"`
FeatureUUID string `json:"-"`
ProjectID *int64 `json:"-"`
}
type FeatureNotFoundError ¶ added in v0.6.0
type FeatureNotFoundError struct {
// contains filtered or unexported fields
}
func (FeatureNotFoundError) Error ¶ added in v0.6.0
func (e FeatureNotFoundError) Error() string
type FeatureSegment ¶ added in v0.4.0
type FeatureState ¶
type FeatureState struct {
ID int64 `json:"id,omitempty"`
UUID string `json:"uuid,omitempty"`
FeatureStateValue *FeatureStateValue `json:"feature_state_value"`
Enabled bool `json:"enabled"`
Feature int64 `json:"feature"`
Environment *int64 `json:"environment"`
FeatureSegment *int64 `json:"feature_segment,omitempty"`
EnvironmentKey string `json:"-"`
Segment *int64 `json:"-"`
SegmentPriority *int64 `json:"-"`
}
func (*FeatureState) UnmarshalJSON ¶
func (fs *FeatureState) UnmarshalJSON(data []byte) error
type FeatureStateNotFoundError ¶ added in v0.6.0
type FeatureStateNotFoundError struct {
// contains filtered or unexported fields
}
func (FeatureStateNotFoundError) Error ¶ added in v0.6.0
func (e FeatureStateNotFoundError) Error() string
type FeatureStateValue ¶
type Metadata ¶ added in v0.12.0
type Metadata struct {
ID int64 `json:"id,omitempty"`
ModelField int64 `json:"model_field"`
FieldValue string `json:"field_value"`
}
FieldValue is always a string on the wire, whatever the custom field's configured type. ModelField is a MetadataModelField ID, not a MetadataField ID.
type MetadataEntity ¶ added in v0.12.0
type MetadataEntity string
const ( MetadataEntityFeature MetadataEntity = "feature" MetadataEntitySegment MetadataEntity = "segment" MetadataEntityEnvironment MetadataEntity = "environment" )
type MetadataField ¶ added in v0.12.0
type MetadataField struct {
ID int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Description *string `json:"description"`
Organisation int64 `json:"organisation"`
Project *int64 `json:"project"`
ModelFields []MetadataModelField `json:"model_fields"`
}
MetadataField is a custom field definition. Fields belong to an organisation and may optionally be scoped to a single project.
func (MetadataField) ValidateValue ¶ added in v0.12.0
func (f MetadataField) ValidateValue(value string) error
ValidateValue mirrors MetadataField.is_field_value_valid in api/metadata/models.py. The API remains authoritative: unknown field types are accepted here and left for the server to reject.
type MetadataFieldInvalidValueError ¶ added in v0.12.0
type MetadataFieldInvalidValueError struct {
Name string
FieldType string
Value string
Reason string
}
func (MetadataFieldInvalidValueError) Error ¶ added in v0.12.0
func (e MetadataFieldInvalidValueError) Error() string
type MetadataFieldNotBoundError ¶ added in v0.12.0
func (MetadataFieldNotBoundError) Error ¶ added in v0.12.0
func (e MetadataFieldNotBoundError) Error() string
type MetadataFieldNotFoundError ¶ added in v0.12.0
func (MetadataFieldNotFoundError) Error ¶ added in v0.12.0
func (e MetadataFieldNotFoundError) Error() string
type MetadataFieldResolver ¶ added in v0.12.0
type MetadataFieldResolver struct {
// contains filtered or unexported fields
}
MetadataFieldResolver maps custom field names to MetadataModelField IDs for a single project and entity type, and back again.
func (*MetadataFieldResolver) BoundNames ¶ added in v0.12.0
func (r *MetadataFieldResolver) BoundNames() []string
BoundNames returns the sorted names of the custom fields available for this entity.
func (*MetadataFieldResolver) Field ¶ added in v0.12.0
func (r *MetadataFieldResolver) Field(name string) (MetadataField, bool)
Field returns the definition of a custom field bound to this entity.
func (*MetadataFieldResolver) ModelFieldID ¶ added in v0.12.0
func (r *MetadataFieldResolver) ModelFieldID(name string) (int64, error)
ModelFieldID returns a MetadataFieldNotBoundError if the field exists in the project but is not enabled for this entity, and a MetadataFieldNotFoundError if it does not exist at all.
type MetadataModelField ¶ added in v0.12.0
MetadataModelField binds a custom field to a Django content type, i.e. to features, segments or environments. Its ID is what Metadata.ModelField refers to.
type Organisation ¶ added in v0.10.0
type Project ¶ added in v0.1.0
type Project struct {
ID int64 `json:"id,omitempty"`
UUID string `json:"uuid,omitempty"`
Name string `json:"name"`
Organisation int64 `json:"organisation"`
HideDisabledFlags bool `json:"hide_disabled_flags,omitempty"`
PreventFlagDefaults bool `json:"prevent_flag_defaults,omitempty"`
OnlyAllowLowerCaseFeatureNames bool `json:"only_allow_lower_case_feature_names,omitempty"`
FeatureNameRegex string `json:"feature_name_regex,omitempty"`
StaleFlagsLimitDays int64 `json:"stale_flags_limit_days,omitempty"`
EnableRealtimeUpdates bool `json:"enable_realtime_updates,omitempty"`
EnforceFeatureOwners *bool `json:"enforce_feature_owners,omitempty"`
}
type Segment ¶ added in v0.3.0
type Segment struct {
ID *int64 `json:"id,omitempty"`
UUID string `json:"uuid,omitempty"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
ProjectID *int64 `json:"project"`
ProjectUUID string `json:"-"`
FeatureID *int64 `json:"feature,omitempty"`
Rules []Rule `json:"rules"`
Metadata *[]Metadata `json:"metadata,omitempty"`
}
type SegmentNotFoundError ¶ added in v0.6.0
type SegmentNotFoundError struct {
// contains filtered or unexported fields
}
func (SegmentNotFoundError) Error ¶ added in v0.6.0
func (e SegmentNotFoundError) Error() string
type ServerSideEnvKey ¶ added in v0.9.0
type Trait ¶ added in v0.9.0
type Trait struct {
ID int64 `json:"id,omitempty"`
TraitKey string `json:"trait_key"`
ValueType string `json:"value_type"`
IntegerValue *int `json:"integer_value,omitempty"`
StringValue *string `json:"string_value,omitempty"`
BooleanValue *bool `json:"boolean_value,omitempty"`
FloatValue *float64 `json:"float_value,omitempty"`
}
type UserNotFoundError ¶ added in v0.11.0
type UserNotFoundError struct {
// contains filtered or unexported fields
}
func (UserNotFoundError) Error ¶ added in v0.11.0
func (e UserNotFoundError) Error() string
