// UpgradeSeriesTarget returns the series
// that the machine is being upgraded to.
554884
func (m *Machine) UpgradeSeriesTarget() (string, error) {
	lock, err := m.getUpgradeSeriesLock()
	if err != nil {
		return "", errors.Trace(err)
	}
	return lock.ToSeries, nil
}
1256255
func (s *UpdateCrawlerInput) SetTargets(v *CrawlerTargets) *UpdateCrawlerInput {
	s.Targets = v
	return s
}
129619
func (m *MockUpgradeSeriesMachine) UpgradeSeriesStatus() (model.UpgradeSeriesStatus, error) {
	ret := m.ctrl.Call(m, "UpgradeSeriesStatus")
	ret0, _ := ret[0].(model.UpgradeSeriesStatus)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
825303
func (m *MockFacade) TargetSeries() (string, error) {
	ret := m.ctrl.Call(m, "TargetSeries")
	ret0, _ := ret[0].(string)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
297852
func (w *upgradeSeriesWorker) handleUpgradeSeriesChange() error {
	w.mu.Lock()
	defer w.mu.Unlock()

	var err error
	if w.machineStatus, err = w.MachineStatus(); err != nil {
		if errors.IsNotFound(err) {
			// No upgrade-series lock. This can happen when:
			// - The first watch call is made.
			// - The lock is removed after a completed upgrade.
			w.logger.Infof("no series upgrade lock present")
			w.machineStatus = model.UpgradeSeriesNotStarted
			w.preparedUnits = nil
			w.completedUnits = nil
			return nil
		}
		return errors.Trace(err)
	}
	w.logger.Infof("machine series upgrade status is %q", w.machineStatus)

	switch w.machineStatus {
	case model.UpgradeSeriesPrepareStarted:
		err = w.handlePrepareStarted()
	case model.UpgradeSeriesCompleteStarted:
		err = w.handleCompleteStarted()
	case model.UpgradeSeriesCompleted:
		err = w.handleCompleted()
	}
	return errors.Trace(err)
}
697904
func (api *APIBase) UpdateApplicationSeries(args params.UpdateSeriesArgs) (params.ErrorResults, error) {
	if err := api.checkCanWrite(); err != nil {
		return params.ErrorResults{}, err
	}
	if err := api.check.ChangeAllowed(); err != nil {
		return params.ErrorResults{}, errors.Trace(err)
	}
	results := params.ErrorResults{
		Results: make([]params.ErrorResult, len(args.Args)),
	}
	for i, arg := range args.Args {
		err := api.updateOneApplicationSeries(arg)
		results.Results[i].Error = common.ServerError(err)
	}
	return results, nil
}
937904
func (s *DomainEntry) SetTarget(v string) *DomainEntry {
	s.Target = &v
	return s
}
150979
func (s *DBEngineVersion) SetValidUpgradeTarget(v []*UpgradeTarget) *DBEngineVersion {
	s.ValidUpgradeTarget = v
	return s
}
46352
func (s *OTAUpdateInfo) SetTargets(v []*string) *OTAUpdateInfo {
	s.Targets = v
	return s
}
868910
func (u *Unit) UpgradeSeriesStatus() (model.UpgradeSeriesStatus, error) {
	res, err := u.st.UpgradeSeriesUnitStatus()
	if err != nil {
		return "", errors.Trace(err)
	}
	if len(res) != 1 {
		return "", errors.Errorf("expected 1 result, got %d", len(res))
	}
	return res[0], nil
}
242766
func PerformUpgrade(from version.Number, targets []Target, context Context) error {
	if hasStateTarget(targets) {
		ops := newStateUpgradeOpsIterator(from)
		if err := runUpgradeSteps(ops, targets, context.StateContext()); err != nil {
			return err
		}
	}
	ops := newUpgradeOpsIterator(from)
	if err := runUpgradeSteps(ops, targets, context.APIContext()); err != nil {
		return err
	}
	logger.Infof("All upgrade steps completed successfully")
	return nil
}
153409
func NewUpgradeSeriesAPI(facade base.FacadeCaller, tag names.Tag) *UpgradeSeriesAPI {
	return &UpgradeSeriesAPI{facade: facade, tag: tag}
}
697253
func (client *Client) UpgradeSeriesPrepare(machineName, series string, force bool) error {
	if client.BestAPIVersion() < 5 {
		return errors.NotSupportedf("upgrade-series prepare")
	}
	args := params.UpdateSeriesArg{
		Entity: params.Entity{
			Tag: names.NewMachineTag(machineName).String()},
		Series: series,
		Force:  force,
	}
	result := params.ErrorResult{}
	if err := client.facade.FacadeCall("UpgradeSeriesPrepare", args, &result); err != nil {
		return errors.Trace(err)
	}

	err := result.Error
	if err != nil {
		return common.RestoreError(err)
	}
	return nil
}
497114
func (c *Client) UpdateApplicationSeries(appName, series string, force bool) error {
	args := params.UpdateSeriesArgs{
		Args: []params.UpdateSeriesArg{{
			Entity: params.Entity{Tag: names.NewApplicationTag(appName).String()},
			Force:  force,
			Series: series,
		}},
	}

	results := new(params.ErrorResults)
	err := c.facade.FacadeCall("UpdateApplicationSeries", args, results)
	if err != nil {
		return errors.Trace(err)
	}
	return results.OneError()
}
1263097
func (s *PresetWatermark) SetTarget(v string) *PresetWatermark {
	s.Target = &v
	return s
}
824601
func (s *AssociationVersionInfo) SetTargets(v []*Target) *AssociationVersionInfo {
	s.Targets = v
	return s
}
1253074
func (s *ScraperTargetStoreService) UpdateTarget(ctx context.Context, t *platform.ScraperTarget, userID platform.ID) (*platform.ScraperTarget, error) {
	return s.UpdateTargetF(ctx, t, userID)
}