// Code generated by oagen. DO NOT EDIT.

package workos

import (
	
	
	
)

// FeatureFlagService handles FeatureFlags operations.
type FeatureFlagService struct {
	client *Client
}

// FeatureFlagsListParams contains the parameters for List.
type FeatureFlagsListParams struct {
	PaginationParams
}

// List feature flags
// Get a list of all of your existing feature flags matching the criteria specified.
func ( *FeatureFlagService) ( context.Context,  *FeatureFlagsListParams,  ...RequestOption) *Iterator[Flag] {
	return newIterator[Flag](, .client, "GET", "/feature-flags", , "after", "data", , map[string]string{"limit": "10", "order": "desc"})
}

// Get a feature flag
// Get the details of an existing feature flag by its slug.
func ( *FeatureFlagService) ( context.Context,  string,  ...RequestOption) (*Flag, error) {
	var  Flag
	,  := .client.request(, "GET", fmt.Sprintf("/feature-flags/%s", url.PathEscape()), nil, nil, &, )
	if  != nil {
		return nil, 
	}
	return &, nil
}

// Disable a feature flag
// Disables a feature flag in the current environment.
func ( *FeatureFlagService) ( context.Context,  string,  ...RequestOption) (*FeatureFlag, error) {
	var  FeatureFlag
	,  := .client.request(, "PUT", fmt.Sprintf("/feature-flags/%s/disable", url.PathEscape()), nil, nil, &, )
	if  != nil {
		return nil, 
	}
	return &, nil
}

// Enable a feature flag
// Enables a feature flag in the current environment.
func ( *FeatureFlagService) ( context.Context,  string,  ...RequestOption) (*FeatureFlag, error) {
	var  FeatureFlag
	,  := .client.request(, "PUT", fmt.Sprintf("/feature-flags/%s/enable", url.PathEscape()), nil, nil, &, )
	if  != nil {
		return nil, 
	}
	return &, nil
}

// AddFlagTarget add a feature flag target
// Enables a feature flag for a specific target in the current environment. Currently, supported targets include users and organizations.
func ( *FeatureFlagService) ( context.Context,  string,  string,  ...RequestOption) error {
	,  := .client.request(, "POST", fmt.Sprintf("/feature-flags/%s/targets/%s", url.PathEscape(), url.PathEscape()), nil, nil, nil, )
	return 
}

// RemoveFlagTarget remove a feature flag target
// Removes a target from the feature flag's target list in the current environment. Currently, supported targets include users and organizations.
func ( *FeatureFlagService) ( context.Context,  string,  string,  ...RequestOption) error {
	,  := .client.request(, "DELETE", fmt.Sprintf("/feature-flags/%s/targets/%s", url.PathEscape(), url.PathEscape()), nil, nil, nil, )
	return 
}

// FeatureFlagsListOrganizationFeatureFlagsParams contains the parameters for ListOrganizationFeatureFlags.
type FeatureFlagsListOrganizationFeatureFlagsParams struct {
	PaginationParams
}

// ListOrganizationFeatureFlags list enabled feature flags for an organization
// Get a list of all enabled feature flags for an organization.
func ( *FeatureFlagService) ( context.Context,  string,  *FeatureFlagsListOrganizationFeatureFlagsParams,  ...RequestOption) *Iterator[Flag] {
	return newIterator[Flag](, .client, "GET", fmt.Sprintf("/organizations/%s/feature-flags", url.PathEscape()), , "after", "data", , map[string]string{"limit": "10", "order": "desc"})
}

// FeatureFlagsListUserFeatureFlagsParams contains the parameters for ListUserFeatureFlags.
type FeatureFlagsListUserFeatureFlagsParams struct {
	PaginationParams
}

// ListUserFeatureFlags list enabled feature flags for a user
// Get a list of all enabled feature flags for the provided user. This includes feature flags enabled specifically for the user as well as any organizations that the user is a member of.
func ( *FeatureFlagService) ( context.Context,  string,  *FeatureFlagsListUserFeatureFlagsParams,  ...RequestOption) *Iterator[Flag] {
	return newIterator[Flag](, .client, "GET", fmt.Sprintf("/user_management/users/%s/feature-flags", url.PathEscape()), , "after", "data", , map[string]string{"limit": "10", "order": "desc"})
}