//
// NewOptions - return a string representation of the enum
//
195373
func NewOptions(init ...interface{}) Options {
	if len(init) == 1 {
		switch v := init[0].(type) {
		case Options:
			return v
		case int:
			return Options(v)
		case int32:
			return Options(v)
		case string:
			for i, s := range namesOptions {
				if s == v {
					return Options(i)
				}
			}
		default:
			panic("Bad init value for Options enum")
		}
	}
	return Options(0) //default to the first enum value
}
830076
func newOptions(eval *evalVisitor, params []interface{}, hash map[string]interface{}) *Options {
	return &Options{
		eval:   eval,
		params: params,
		hash:   hash,
	}
}
1271167
func (s *DescribeConfigurationOptionsOutput) SetOptions(v []*ConfigurationOptionDescription) *DescribeConfigurationOptionsOutput {
	s.Options = v
	return s
}
351416
func (s *DescribeTaskOutput) SetOptions(v *Options) *DescribeTaskOutput {
	s.Options = v
	return s
}
683423
func (c Configuration) NewOptions(scope tally.Scope) Options {
	opts := NewOptions().SetMetricsScope(scope)
	if c.InitialBackoff != 0 {
		opts = opts.SetInitialBackoff(c.InitialBackoff)
	}
	if c.BackoffFactor != 0.0 {
		opts = opts.SetBackoffFactor(c.BackoffFactor)
	}
	if c.MaxBackoff != 0 {
		opts = opts.SetMaxBackoff(c.MaxBackoff)
	}
	if c.MaxRetries != 0 {
		opts = opts.SetMaxRetries(c.MaxRetries)
	}
	if c.Forever != nil {
		opts = opts.SetForever(*c.Forever)
	}
	if c.Jitter != nil {
		opts = opts.SetJitter(*c.Jitter)
	}

	return opts
}
207340
func NewOptions(db *gorm.DB, opts Options, keyPairs ...[]byte) *Store {
	st := &Store{
		db:     db,
		opts:   opts,
		Codecs: securecookie.CodecsFromPairs(keyPairs...),
		SessionOpts: &sessions.Options{
			Path:   defaultPath,
			MaxAge: defaultMaxAge,
		},
	}
	if st.opts.TableName == "" {
		st.opts.TableName = defaultTableName
	}

	if !st.opts.SkipCreateTable {
		st.db.AutoMigrate(&gormSession{tableName: st.opts.TableName})
	}

	return st
}
232713
func Options(nopts nats.Options) registry.Option {
	return func(o *registry.Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}
		o.Context = context.WithValue(o.Context, optionsKey{}, nopts)
	}
}
1293234
func (s *LogPublishingOptionsStatus) SetOptions(v map[string]*LogPublishingOption) *LogPublishingOptionsStatus {
	s.Options = v
	return s
}
1058502
func NewOptions(max int, options ...Option) *ProgressBar {
	return NewOptions64(int64(max), options...)
}
509005
func NewNatsOptions(optionFuncs ...OptionsFunc) (options *NatsOptions) {
	options = &NatsOptions{Options: nats.DefaultOptions}
	options.setOptions(prepend(optionFuncs, setDefaultOptions)...)
	return
}
817880
func NewOptionList(permissibleOptions []string, defaultOptions string) (*OptionList, error) {
	permissible := make(map[string]struct{})
	ol := &OptionList{
		allOptions:  permissibleOptions,
		permissible: permissible,
		typeName:    "OptionList",
	}

	for _, o := range permissibleOptions {
		ol.permissible[o] = struct{}{}
	}

	if err := ol.Set(defaultOptions); err != nil {
		return nil, errwrap.Wrap(errors.New("problem setting defaults"), err)
	}

	return ol, nil
}
1223767
func (p *parser) EnumString(i int, context string, options ...string) string {
	s := p.String(i, context)
	if p.err != nil || s == "" {
		return ""
	}
	for _, o := range options {
		if o == s {
			return s
		}
	}
	p.SetErr(context, s)
	return ""
}
261418
func NewOptions() Options {
	logger := log.NewLevelLogger(log.SimpleLogger, log.LevelInfo)
	return &options{
		logger:         logger,
		zap:            zap.L(),
		scope:          tally.NoopScope,
		samplingRate:   defaultSamplingRate,
		reportInterval: defaultReportingInterval,
	}
}
722805
func (s *AdvancedOptionsStatus) SetOptions(v map[string]*string) *AdvancedOptionsStatus {
	s.Options = v
	return s
}
799116
func (s *AvailabilityOptionsStatus) SetOptions(v bool) *AvailabilityOptionsStatus {
	s.Options = &v
	return s
}
489909
func (s *UpdateTaskInput) SetOptions(v *Options) *UpdateTaskInput {
	s.Options = v
	return s
}
657348
func NewRequestOptions(r *http.Request) *RequestOptions {
	if reqOpt := getFromForm(r.URL.Query()); reqOpt != nil {
		return reqOpt
	}

	if r.Method != http.MethodPost {
		return &RequestOptions{}
	}

	if r.Body == nil {
		return &RequestOptions{}
	}

	// TODO: improve Content-Type handling
	contentTypeStr := r.Header.Get("Content-Type")
	contentTypeTokens := strings.Split(contentTypeStr, ";")
	contentType := contentTypeTokens[0]

	switch contentType {
	case ContentTypeGraphQL:
		body, err := ioutil.ReadAll(r.Body)
		if err != nil {
			return &RequestOptions{}
		}
		return &RequestOptions{
			Query: string(body),
		}
	case ContentTypeFormURLEncoded:
		if err := r.ParseForm(); err != nil {
			return &RequestOptions{}
		}

		if reqOpt := getFromForm(r.PostForm); reqOpt != nil {
			return reqOpt
		}

		return &RequestOptions{}

	case ContentTypeJSON:
		fallthrough
	default:
		var opts RequestOptions
		body, err := ioutil.ReadAll(r.Body)
		if err != nil {
			return &opts
		}
		err = json.Unmarshal(body, &opts)
		if err != nil {
			// Probably `variables` was sent as a string instead of an object.
			// So, we try to be polite and try to parse that as a JSON string
			var optsCompatible requestOptionsCompatibility
			json.Unmarshal(body, &optsCompatible)
			json.Unmarshal([]byte(optsCompatible.Variables), &opts.Variables)
		}
		return &opts
	}
}