// updateApplication adds or updates the application in the specified model.
961829
func (c *Controller) updateApplication(ch ApplicationChange) {
	c.ensureModel(ch.ModelUUID).updateApplication(ch, c.manager)
}
1214218
func (s *DeleteApnsVoipChannelInput) SetApplicationId(v string) *DeleteApnsVoipChannelInput {
	s.ApplicationId = &v
	return s
}
734342
func (client *Client) CreateApplication(app Application) (Application, Warnings, error) {
	body, err := json.Marshal(app)
	if err != nil {
		return Application{}, nil, err
	}

	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.PostAppRequest,
		Body:        bytes.NewReader(body),
	})
	if err != nil {
		return Application{}, nil, err
	}

	var updatedApp Application
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &updatedApp,
	}

	err = client.connection.Make(request, &response)
	return updatedApp, response.Warnings, err
}
1131509
func (s *Image) SetApplications(v []*Application) *Image {
	s.Applications = v
	return s
}
666089
func (s *RobotApplicationConfig) SetApplication(v string) *RobotApplicationConfig {
	s.Application = &v
	return s
}
324346
func (s *Version) SetApplicationId(v string) *Version {
	s.ApplicationId = &v
	return s
}
753605
func (s *UpdateVoiceChannelInput) SetApplicationId(v string) *UpdateVoiceChannelInput {
	s.ApplicationId = &v
	return s
}
1306244
func (s *APNSVoipSandboxChannelResponse) SetApplicationId(v string) *APNSVoipSandboxChannelResponse {
	s.ApplicationId = &v
	return s
}
377765
func (s *VersionSummary) SetApplicationId(v string) *VersionSummary {
	s.ApplicationId = &v
	return s
}
389438
func (s *CreateCloudFormationChangeSetRequest) SetApplicationId(v string) *CreateCloudFormationChangeSetRequest {
	s.ApplicationId = &v
	return s
}
585539
func (s *GetSegmentImportJobsInput) SetApplicationId(v string) *GetSegmentImportJobsInput {
	s.ApplicationId = &v
	return s
}
734292
func (s *UpdateApnsVoipSandboxChannelInput) SetApplicationId(v string) *UpdateApnsVoipSandboxChannelInput {
	s.ApplicationId = &v
	return s
}
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")
}
97120
func (client *Client) UpdateApplication(app Application) (Application, Warnings, error) {
	bodyBytes, err := json.Marshal(app)
	if err != nil {
		return Application{}, nil, err
	}

	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.PatchApplicationRequest,
		Body:        bytes.NewReader(bodyBytes),
		URIParams:   map[string]string{"app_guid": app.GUID},
	})
	if err != nil {
		return Application{}, nil, err
	}

	var responseApp Application
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &responseApp,
	}
	err = client.connection.Make(request, &response)

	return responseApp, response.Warnings, err
}
555963
func (s *GetCampaignActivitiesInput) SetApplicationId(v string) *GetCampaignActivitiesInput {
	s.ApplicationId = &v
	return s
}
76342
func (c *Client) Update(args params.ApplicationUpdate) error {
	return c.facade.FacadeCall("Update", args, nil)
}
626473
func (s *UpdateCampaignInput) SetApplicationId(v string) *UpdateCampaignInput {
	s.ApplicationId = &v
	return s
}