func (config *SAMLProviderConfigToUpdate) RequestSigningEnabled(enabled bool) *SAMLProviderConfigToUpdate {
	return config.set(signRequestKey, enabled)
}
RequestSigningEnabled enables or disables the request signing support.
package auth
import (
	"context"
	"errors"
	"fmt"
	"net/http"
	"net/url"
	"strconv"
	"strings"
	"firebase.google.com/go/v4/internal"
	"google.golang.org/api/iterator"
)
const (
	maxConfigs = 100
	idpEntityIDKey = "idpConfig.idpEntityId"
	ssoURLKey      = "idpConfig.ssoUrl"
	signRequestKey = "idpConfig.signRequest"
	idpCertsKey    = "idpConfig.idpCertificates"
	spEntityIDKey  = "spConfig.spEntityId"
	callbackURIKey = "spConfig.callbackUri"
	clientIDKey = "clientId"
	issuerKey   = "issuer"
	displayNameKey = "displayName"
	enabledKey     = "enabled"
)
type nestedMap map[string]interface{}
func (nm nestedMap) Get(key string) (interface{}, bool) {
	segments := strings.Split(key, ".")
	curr := map[string]interface{}(nm)
	for idx, segment := range segments {
		val, ok := curr[segment]
		if idx == len(segments)-1 || !ok {
			return val, ok
		}
		curr = val.(map[string]interface{})
	}
	return nil, false
}
func (nm nestedMap) GetString(key string) (string, bool) {
	if val, ok := nm.Get(key); ok {
		return val.(string), true
	}
	return "", false
}
func (nm nestedMap) Set(key string, value interface{}) {
	segments := strings.Split(key, ".")
	curr := map[string]interface{}(nm)
	for idx, segment := range segments {
		if idx == len(segments)-1 {
			curr[segment] = value
			return
		}
		child, ok := curr[segment]
		if ok {
			curr = child.(map[string]interface{})
			continue
		}
		newChild := make(map[string]interface{})
		curr[segment] = newChild
		curr = newChild
	}
}
func (nm nestedMap) UpdateMask() []string {
	return buildMask(nm)
}
func buildMask(data map[string]interface{}) []string {
	var mask []string
	for k, v := range data {
		if child, ok := v.(map[string]interface{}); ok {
			childMask := buildMask(child)
			for _, item := range childMask {
				mask = append(mask, fmt.Sprintf("%s.%s", k, item))
			}
		} else {
			mask = append(mask, k)
		}
	}
	return mask
}
type OIDCProviderConfig struct {
	ID          string
	DisplayName string
	Enabled     bool
	ClientID    string
	Issuer      string
}
type OIDCProviderConfigToCreate struct {
	id     string
	params nestedMap
}
func (config *OIDCProviderConfigToCreate) ID(id string) *OIDCProviderConfigToCreate {
	config.id = id
	return config
}
func (config *OIDCProviderConfigToCreate) ClientID(clientID string) *OIDCProviderConfigToCreate {
	return config.set(clientIDKey, clientID)
}
func (config *OIDCProviderConfigToCreate) Issuer(issuer string) *OIDCProviderConfigToCreate {
	return config.set(issuerKey, issuer)
}
func (config *OIDCProviderConfigToCreate) DisplayName(name string) *OIDCProviderConfigToCreate {
	return config.set(displayNameKey, name)
}
func (config *OIDCProviderConfigToCreate) Enabled(enabled bool) *OIDCProviderConfigToCreate {
	return config.set(enabledKey, enabled)
}
func (config *OIDCProviderConfigToCreate) set(key string, value interface{}) *OIDCProviderConfigToCreate {
	if config.params == nil {
		config.params = make(nestedMap)
	}
	config.params.Set(key, value)
	return config
}
func (config *OIDCProviderConfigToCreate) buildRequest() (nestedMap, string, error) {
	if err := validateOIDCConfigID(config.id); err != nil {
		return nil, "", err
	}
	if len(config.params) == 0 {
		return nil, "", errors.New("no parameters specified in the create request")
	}
	if val, ok := config.params.GetString(clientIDKey); !ok || val == "" {
		return nil, "", errors.New("ClientID must not be empty")
	}
	if val, ok := config.params.GetString(issuerKey); !ok || val == "" {
		return nil, "", errors.New("Issuer must not be empty")
	} else if _, err := url.ParseRequestURI(val); err != nil {
		return nil, "", fmt.Errorf("failed to parse Issuer: %v", err)
	}
	return config.params, config.id, nil
}
type OIDCProviderConfigToUpdate struct {
	params nestedMap
}
func (config *OIDCProviderConfigToUpdate) ClientID(clientID string) *OIDCProviderConfigToUpdate {
	return config.set(clientIDKey, clientID)
}
func (config *OIDCProviderConfigToUpdate) Issuer(issuer string) *OIDCProviderConfigToUpdate {
	return config.set(issuerKey, issuer)
}
func (config *OIDCProviderConfigToUpdate) DisplayName(name string) *OIDCProviderConfigToUpdate {
	var nameOrNil interface{}
	if name != "" {
		nameOrNil = name
	}
	return config.set(displayNameKey, nameOrNil)
}
func (config *OIDCProviderConfigToUpdate) Enabled(enabled bool) *OIDCProviderConfigToUpdate {
	return config.set(enabledKey, enabled)
}
func (config *OIDCProviderConfigToUpdate) set(key string, value interface{}) *OIDCProviderConfigToUpdate {
	if config.params == nil {
		config.params = make(nestedMap)
	}
	config.params.Set(key, value)
	return config
}
func (config *OIDCProviderConfigToUpdate) buildRequest() (nestedMap, error) {
	if len(config.params) == 0 {
		return nil, errors.New("no parameters specified in the update request")
	}
	if val, ok := config.params.GetString(clientIDKey); ok && val == "" {
		return nil, errors.New("ClientID must not be empty")
	}
	if val, ok := config.params.GetString(issuerKey); ok {
		if val == "" {
			return nil, errors.New("Issuer must not be empty")
		}
		if _, err := url.ParseRequestURI(val); err != nil {
			return nil, fmt.Errorf("failed to parse Issuer: %v", err)
		}
	}
	return config.params, nil
}
type OIDCProviderConfigIterator struct {
	client   *baseClient
	ctx      context.Context
	nextFunc func() error
	pageInfo *iterator.PageInfo
	configs  []*OIDCProviderConfig
}
func (it *OIDCProviderConfigIterator) PageInfo() *iterator.PageInfo {
	return it.pageInfo
}
func (it *OIDCProviderConfigIterator) Next() (*OIDCProviderConfig, error) {
	if err := it.nextFunc(); err != nil {
		return nil, err
	}
	config := it.configs[0]
	it.configs = it.configs[1:]
	return config, nil
}
func (it *OIDCProviderConfigIterator) fetch(pageSize int, pageToken string) (string, error) {
	params := map[string]string{
		"pageSize": strconv.Itoa(pageSize),
	}
	if pageToken != "" {
		params["pageToken"] = pageToken
	}
	req := &internal.Request{
		Method: http.MethodGet,
		URL:    "/oauthIdpConfigs",
		Opts: []internal.HTTPOption{
			internal.WithQueryParams(params),
		},
	}
	var result struct {
		Configs       []oidcProviderConfigDAO `json:"oauthIdpConfigs"`
		NextPageToken string                  `json:"nextPageToken"`
	}
	if _, err := it.client.makeRequest(it.ctx, req, &result); err != nil {
		return "", err
	}
	for _, config := range result.Configs {
		it.configs = append(it.configs, config.toOIDCProviderConfig())
	}
	it.pageInfo.Token = result.NextPageToken
	return result.NextPageToken, nil
}
type SAMLProviderConfig struct {
	ID                    string
	DisplayName           string
	Enabled               bool
	IDPEntityID           string
	SSOURL                string
	RequestSigningEnabled bool
	X509Certificates      []string
	RPEntityID            string
	CallbackURL           string
}
type SAMLProviderConfigToCreate struct {
	id     string
	params nestedMap
}
func (config *SAMLProviderConfigToCreate) ID(id string) *SAMLProviderConfigToCreate {
	config.id = id
	return config
}
func (config *SAMLProviderConfigToCreate) IDPEntityID(entityID string) *SAMLProviderConfigToCreate {
	return config.set(idpEntityIDKey, entityID)
}
func (config *SAMLProviderConfigToCreate) SSOURL(url string) *SAMLProviderConfigToCreate {
	return config.set(ssoURLKey, url)
}
func (config *SAMLProviderConfigToCreate) RequestSigningEnabled(enabled bool) *SAMLProviderConfigToCreate {
	return config.set(signRequestKey, enabled)
}
func (config *SAMLProviderConfigToCreate) X509Certificates(certs []string) *SAMLProviderConfigToCreate {
	var result []idpCertificate
	for _, cert := range certs {
		result = append(result, idpCertificate{cert})
	}
	return config.set(idpCertsKey, result)
}
func (config *SAMLProviderConfigToCreate) RPEntityID(entityID string) *SAMLProviderConfigToCreate {
	return config.set(spEntityIDKey, entityID)
}
func (config *SAMLProviderConfigToCreate) CallbackURL(url string) *SAMLProviderConfigToCreate {
	return config.set(callbackURIKey, url)
}
func (config *SAMLProviderConfigToCreate) DisplayName(name string) *SAMLProviderConfigToCreate {
	return config.set(displayNameKey, name)
}
func (config *SAMLProviderConfigToCreate) Enabled(enabled bool) *SAMLProviderConfigToCreate {
	return config.set(enabledKey, enabled)
}
func (config *SAMLProviderConfigToCreate) set(key string, value interface{}) *SAMLProviderConfigToCreate {
	if config.params == nil {
		config.params = make(nestedMap)
	}
	config.params.Set(key, value)
	return config
}
func (config *SAMLProviderConfigToCreate) buildRequest() (nestedMap, string, error) {
	if err := validateSAMLConfigID(config.id); err != nil {
		return nil, "", err
	}
	if len(config.params) == 0 {
		return nil, "", errors.New("no parameters specified in the create request")
	}
	if val, ok := config.params.GetString(idpEntityIDKey); !ok || val == "" {
		return nil, "", errors.New("IDPEntityID must not be empty")
	}
	if val, ok := config.params.GetString(ssoURLKey); !ok || val == "" {
		return nil, "", errors.New("SSOURL must not be empty")
	} else if _, err := url.ParseRequestURI(val); err != nil {
		return nil, "", fmt.Errorf("failed to parse SSOURL: %v", err)
	}
	var certs interface{}
	var ok bool
	if certs, ok = config.params.Get(idpCertsKey); !ok || len(certs.([]idpCertificate)) == 0 {
		return nil, "", errors.New("X509Certificates must not be empty")
	}
	for _, cert := range certs.([]idpCertificate) {
		if cert.X509Certificate == "" {
			return nil, "", errors.New("X509Certificates must not contain empty strings")
		}
	}
	if val, ok := config.params.GetString(spEntityIDKey); !ok || val == "" {
		return nil, "", errors.New("RPEntityID must not be empty")
	}
	if val, ok := config.params.GetString(callbackURIKey); !ok || val == "" {
		return nil, "", errors.New("CallbackURL must not be empty")
	} else if _, err := url.ParseRequestURI(val); err != nil {
		return nil, "", fmt.Errorf("failed to parse CallbackURL: %v", err)
	}
	return config.params, config.id, nil
}
type SAMLProviderConfigToUpdate struct {
	params nestedMap
}
func (config *SAMLProviderConfigToUpdate) IDPEntityID(entityID string) *SAMLProviderConfigToUpdate {
	return config.set(idpEntityIDKey, entityID)
}
func (config *SAMLProviderConfigToUpdate) SSOURL(url string) *SAMLProviderConfigToUpdate {
	return config.set(ssoURLKey, url)
}