// Settings of the model.
779173
func (m *HoltWintersMovAvgModel) Settings() map[string]interface{} {
	settings := make(map[string]interface{})
	if m.alpha != nil {
		settings["alpha"] = *m.alpha
	}
	if m.beta != nil {
		settings["beta"] = *m.beta
	}
	if m.gamma != nil {
		settings["gamma"] = *m.gamma
	}
	if m.period != nil {
		settings["period"] = *m.period
	}
	if m.pad != nil {
		settings["pad"] = *m.pad
	}
	if m.seasonalityType != "" {
		settings["type"] = m.seasonalityType
	}
	return settings
}
911639
func (c *Client) HostedModelConfigs() ([]HostedConfig, error) {
	result := params.HostedModelConfigsResults{}
	err := c.facade.FacadeCall("HostedModelConfigs", nil, &result)
	if err != nil {
		return nil, errors.Trace(err)
	}
	// If we get to here, we have some values. Each value may or
	// may not have an error, but it should at least have a name
	// and owner.
	hostedConfigs := make([]HostedConfig, len(result.Models))
	for i, modelConfig := range result.Models {
		hostedConfigs[i].Name = modelConfig.Name
		tag, err := names.ParseUserTag(modelConfig.OwnerTag)
		if err != nil {
			hostedConfigs[i].Error = errors.Trace(err)
			continue
		}
		hostedConfigs[i].Owner = tag
		if modelConfig.Error != nil {
			hostedConfigs[i].Error = errors.Trace(modelConfig.Error)
			continue
		}
		hostedConfigs[i].Config = modelConfig.Config
		spec, err := c.MakeCloudSpec(modelConfig.CloudSpec)
		if err != nil {
			hostedConfigs[i].Error = errors.Trace(err)
			continue
		}
		hostedConfigs[i].CloudSpec = spec
	}
	return hostedConfigs, err
}
922022
func (e *Enforcer) LoadModel() {
	e.model = NewModel()
	e.model.LoadModel(e.modelPath)
	e.model.PrintModel()
	e.fm = model.LoadFunctionMap()
}
483505
func (b *SqliteBuilder) Model(model interface{}) *ModelQuery {
	return NewModelQuery(model, b.db.FieldMapper, b.db, b)
}
1250354
func (mr *MockStateModelMockRecorder) ModelConfig() *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModelConfig", reflect.TypeOf((*MockStateModel)(nil).ModelConfig))
}
33638
func (a *MovAvgAggregation) Model(model MovAvgModel) *MovAvgAggregation {
	a.model = model
	return a
}
289558
func (s *store) SetModels(controllerName string, models map[string]ModelDetails) error {
	if err := ValidateControllerName(controllerName); err != nil {
		return errors.Trace(err)
	}

	for modelName, details := range models {
		if err := ValidateModel(modelName, details); err != nil {
			return errors.Trace(err)
		}
	}

	releaser, err := s.acquireLock()
	if err != nil {
		return errors.Annotatef(err,
			"cannot acquire lock file for setting models on controller %s", controllerName,
		)
	}
	defer releaser.Release()

	err = updateModels(controllerName, func(storedModels *ControllerModels) (bool, error) {
		changed := len(storedModels.Models) != len(models)
		// Add or update controller models based on a new collection.
		for modelName, details := range models {
			oldDetails, ok := storedModels.Models[modelName]
			if ok && details == oldDetails {
				continue
			}
			if details.ActiveBranch == "" {
				if oldDetails.ActiveBranch != "" {
					details.ActiveBranch = oldDetails.ActiveBranch
				} else {
					details.ActiveBranch = model.GenerationMaster
				}
			}
			storedModels.Models[modelName] = details
			changed = true
		}
		// Delete models that are not in the new collection.
		for modelName := range storedModels.Models {
			if _, ok := models[modelName]; !ok {
				delete(storedModels.Models, modelName)
			}
		}
		return changed, nil
	})
	if err != nil {
		return errors.Trace(err)
	}
	return nil
}
667292
func (s *SnapshotCreateRepositoryService) Setting(name string, value interface{}) *SnapshotCreateRepositoryService {
	if s.settings == nil {
		s.settings = make(map[string]interface{})
	}
	s.settings[name] = value
	return s
}
404499
func InitModels() {
	index := mgo.Index{
		Key:      []string{"username"},
		Unique:   true,
		DropDups: true,
	}
	db.EnsureIndex(mongoCollectionName, index)

	index = mgo.Index{
		Key:      []string{"username", "token"},
		Unique:   true,
		DropDups: true,
	}
	db.EnsureIndex(mongoCollectionNameResetToken, index)

	automaticExpiration := mgo.Index{
		Key:         []string{"createdat"},
		ExpireAfter: time.Minute * 10,
		Background:  true,
	}
	db.EnsureIndex(mongoCollectionNameResetToken, automaticExpiration)
}
106529
func InitModels() {
	index := mgo.Index{
		Key:    []string{"key"},
		Unique: false,
	}

	db.EnsureIndex(mongoPersistenLogCollectionName, index)
}
1264525
func (chat *Chat) Settings(out interface{}) error {

	data, err := chat.getData()

	if err != nil {
		return err
	}
	serviceID := chat.ctx.getServiceID()

	if _, ok := data.Settings[serviceID]; ok {
		// TODO: workaround that creepy bindInterfaceToInterface
		err = bindInterfaceToInterface(data.Settings[serviceID], out)
		return err
	}

	// Not a error – just empty settings
	return nil
}
668204
func (st *State) SetModelConstraints(cons constraints.Value) error {
	unsupported, err := st.validateConstraints(cons)
	if len(unsupported) > 0 {
		logger.Warningf(
			"setting model constraints: unsupported constraints: %v", strings.Join(unsupported, ","))
	} else if err != nil {
		return errors.Trace(err)
	}
	return writeConstraints(st, modelGlobalKey, cons)
}
771427
func (c *configCommand) modelConfigDetails() (map[string]interface{}, error) {

	defaultSchema, err := config.Schema(nil)
	if err != nil {
		return nil, err
	}
	specifics := make(map[string]interface{})
	for key, attr := range defaultSchema {
		if attr.Secret || c.isModelAttribute(key) ||
			attr.Group != environschema.EnvironGroup {
			continue
		}
		specifics[key] = common.PrintConfigSchema{
			Description: attr.Description,
			Type:        fmt.Sprintf("%s", attr.Type),
		}
	}
	return specifics, nil
}
25495
func (api *RemoteRelationsAPI) RelationUnitSettings(relationUnits params.RelationUnits) (params.SettingsResults, error) {
	results := params.SettingsResults{
		Results: make([]params.SettingsResult, len(relationUnits.RelationUnits)),
	}
	one := func(ru params.RelationUnit) (params.Settings, error) {
		relationTag, err := names.ParseRelationTag(ru.Relation)
		if err != nil {
			return nil, errors.Trace(err)
		}
		rel, err := api.st.KeyRelation(relationTag.Id())
		if err != nil {
			return nil, errors.Trace(err)
		}
		unitTag, err := names.ParseUnitTag(ru.Unit)
		if err != nil {
			return nil, errors.Trace(err)
		}
		unit, err := rel.Unit(unitTag.Id())
		if err != nil {
			return nil, errors.Trace(err)
		}
		settings, err := unit.Settings()
		if err != nil {
			return nil, errors.Trace(err)
		}
		paramsSettings := make(params.Settings)
		for k, v := range settings {
			vString, ok := v.(string)
			if !ok {
				return nil, errors.Errorf(
					"invalid relation setting %q: expected string, got %T", k, v,
				)
			}
			paramsSettings[k] = vString
		}
		return paramsSettings, nil
	}
	for i, ru := range relationUnits.RelationUnits {
		settings, err := one(ru)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		results.Results[i].Settings = settings
	}
	return results, nil
}
383234
func (e *ModelWatcher) ModelConfig() (*config.Config, error) {
	var result params.ModelConfigResult
	err := e.facade.FacadeCall("ModelConfig", nil, &result)
	if err != nil {
		return nil, errors.Trace(err)
	}
	conf, err := config.New(config.NoDefaults, result.Config)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return conf, nil
}
444960
func (u *Unit) ConfigSettings() (charm.Settings, error) {
	if u.doc.CharmURL == nil {
		return nil, fmt.Errorf("unit charm not set")
	}

	// TODO (manadart 2019-02-21) Factor the current generation into this call.
	s, err := charmSettingsWithDefaults(u.st, u.doc.CharmURL, u.doc.Application, model.GenerationMaster)
	if err != nil {
		return nil, errors.Annotatef(err, "charm config for unit %q", u.Name())
	}
	return s, nil
}
1104499
func (a *CellView) SetModel(model CellModel) {
	w, h := model.GetBounds()
	model.SetCursor(0, 0)
	a.model = model
	a.port.SetContentSize(w, h, true)
	a.port.ValidateView()
	a.PostEventWidgetContent(a)
}