// UpdateApplicationSeries updates the series for the Application.
330106
func (a *Application) UpdateApplicationSeries(series string, force bool) (err error) {
	buildTxn := func(attempt int) ([]txn.Op, error) {
		if attempt > 0 {
			// If we've tried once already and failed, re-evaluate the criteria.
			if err := a.Refresh(); err != nil {
				return nil, errors.Trace(err)
			}
		}
		// Exit early if the Application series doesn't need to change.
		if a.Series() == series {
			return nil, jujutxn.ErrNoOperations
		}

		// Verify and gather data for the transaction operations.
		err := a.VerifySupportedSeries(series, force)
		if err != nil {
			return nil, err
		}
		units, err := a.AllUnits()
		if err != nil {
			return nil, errors.Trace(err)
		}
		var subApps []*Application
		var unit *Unit

		if len(units) > 0 {
			// All units have the same subordinates...
			unit = units[0]
			for _, n := range unit.SubordinateNames() {
				app, err := a.st.Application(unitAppName(n))
				if err != nil {
					return nil, err
				}
				err = app.VerifySupportedSeries(series, force)
				if err != nil {
					return nil, err
				}
				subApps = append(subApps, app)
			}
		}

		//Create the transaction operations
		ops := []txn.Op{{
			C:  applicationsC,
			Id: a.doc.DocID,
			Assert: bson.D{{"life", Alive},
				{"charmurl", a.doc.CharmURL},
				{"unitcount", a.doc.UnitCount}},
			Update: bson.D{{"$set", bson.D{{"series", series}}}},
		}}

		if unit != nil {
			ops = append(ops, txn.Op{
				C:  unitsC,
				Id: unit.doc.DocID,
				Assert: bson.D{{"life", Alive},
					{"subordinates", unit.SubordinateNames()}},
			})
		}

		for _, sub := range subApps {
			ops = append(ops, txn.Op{
				C:  applicationsC,
				Id: sub.doc.DocID,
				Assert: bson.D{{"life", Alive},
					{"charmurl", sub.doc.CharmURL},
					{"unitcount", sub.doc.UnitCount}},
				Update: bson.D{{"$set", bson.D{{"series", series}}}},
			})
		}
		return ops, nil
	}

	err = a.st.db().Run(buildTxn)
	return errors.Annotatef(err, "updating application series")
}
117010
func (s *UpdateRobotApplicationInput) SetApplication(v string) *UpdateRobotApplicationInput {
	s.Application = &v
	return s
}
1015677
func (s *DescribeSimulationApplicationInput) SetApplicationVersion(v string) *DescribeSimulationApplicationInput {
	s.ApplicationVersion = &v
	return s
}
151813
func (s *DescribeApplicationStateOutput) SetApplicationStatus(v string) *DescribeApplicationStateOutput {
	s.ApplicationStatus = &v
	return s
}
1324683
func (s *UpdateAdmChannelInput) SetApplicationId(v string) *UpdateAdmChannelInput {
	s.ApplicationId = &v
	return s
}
6197
func (s *Stack) SetApplicationSettings(v *ApplicationSettingsResponse) *Stack {
	s.ApplicationSettings = v
	return s
}
1002849
func (s *ApplicationUpdate) SetApplicationCodeUpdate(v string) *ApplicationUpdate {
	s.ApplicationCodeUpdate = &v
	return s
}
992805
func (s *UpdateGcmChannelInput) SetApplicationId(v string) *UpdateGcmChannelInput {
	s.ApplicationId = &v
	return s
}
961829
func (c *Controller) updateApplication(ch ApplicationChange) {
	c.ensureModel(ch.ModelUUID).updateApplication(ch, c.manager)
}
1042889
func (r *marathonClient) ListApplications(v url.Values) ([]string, error) {
	applications, err := r.Applications(v)
	if err != nil {
		return nil, err
	}
	var list []string
	for _, application := range applications.Apps {
		list = append(list, application.ID)
	}

	return list, nil
}
1001109
func (o *Compute) SetApplications(v []*Application) *Compute {
	if o.Applications = v; o.Applications == nil {
		o.nullFields = append(o.nullFields, "Applications")
	}
	return o
}
1156685
func (m *Model) updateApplication(ch ApplicationChange, rm *residentManager) {
	m.mu.Lock()

	app, found := m.applications[ch.Name]
	if !found {
		app = newApplication(m.metrics, m.hub, rm.new())
		m.applications[ch.Name] = app
	}
	app.setDetails(ch)

	m.mu.Unlock()
}
141625
func (s *DescribeEventsInput) SetApplicationName(v string) *DescribeEventsInput {
	s.ApplicationName = &v
	return s
}
1197490
func (a *Application) UpdateApplicationConfig(
	changes application.ConfigAttributes,
	reset []string,
	schema environschema.Fields,
	defaults schema.Defaults,
) error {
	node, err := readSettings(a.st.db(), settingsC, a.applicationConfigKey())
	if errors.IsNotFound(err) {
		return errors.Errorf("cannot update application config since no config exists for application %v", a.doc.Name)
	} else if err != nil {
		return errors.Annotatef(err, "application config for application %q", a.doc.Name)
	}
	resetKeys := set.NewStrings(reset...)
	for name, value := range changes {
		if resetKeys.Contains(name) {
			continue
		}
		node.Set(name, value)
	}
	for _, name := range reset {
		node.Delete(name)
	}
	newConfig, err := application.NewConfig(node.Map(), schema, defaults)
	if err != nil {
		return errors.Trace(err)
	}
	if err := newConfig.Validate(); err != nil {
		return errors.Trace(err)
	}
	// Update node so it gets coerced values with correct types.
	coerced := newConfig.Attributes()
	for _, key := range node.Keys() {
		node.Set(key, coerced[key])
	}
	_, err = node.Write()
	return err
}
754639
func (s *UpdateApplicationInput) SetApplicationConfigurationUpdate(v *ApplicationConfigurationUpdate) *UpdateApplicationInput {
	s.ApplicationConfigurationUpdate = v
	return s
}
1177767
func (s *ListApplicationsOutput) SetApplications(v []*string) *ListApplicationsOutput {
	s.Applications = v
	return s
}
324346
func (s *Version) SetApplicationId(v string) *Version {
	s.ApplicationId = &v
	return s
}