// RemoteApplications returns the current state of the remote applications with
// the specified names in the local model.
181690
func (c *Client) RemoteApplications(applications []string) ([]params.RemoteApplicationResult, error) {
	args := params.Entities{Entities: make([]params.Entity, len(applications))}
	for i, applicationName := range applications {
		args.Entities[i].Tag = names.NewApplicationTag(applicationName).String()
	}
	var results params.RemoteApplicationResults
	err := c.facade.FacadeCall("RemoteApplications", args, &results)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if len(results.Results) != len(applications) {
		return nil, errors.Errorf("expected %d result(s), got %d", len(applications), len(results.Results))
	}
	return results.Results, nil
}
81541
func (r *marathonClient) UpdateApplication(application *Application, force bool) (*DeploymentID, error) {
	result := new(DeploymentID)
	path := buildPathWithForceParam(application.ID, force)
	if err := r.apiPut(path, application, result); err != nil {
		return nil, err
	}
	return result, nil
}
276603
func (s *BatchGetApplicationsInput) SetApplicationNames(v []*string) *BatchGetApplicationsInput {
	s.ApplicationNames = v
	return s
}
235430
func (s *RunJobFlowInput) SetApplications(v []*Application) *RunJobFlowInput {
	s.Applications = v
	return s
}
46484
func (s *TextOutput) SetAppliedTerminologies(v []*AppliedTerminology) *TextOutput {
	s.AppliedTerminologies = v
	return s
}
1050861
func (s *Cluster) SetApplications(v []*Application) *Cluster {
	s.Applications = v
	return s
}
890059
func (api *Client) GetApplication(id string) (*Application, error) {
	result, _, err := api.makeRequest(http.MethodGet, fmt.Sprintf("%s/%s", api.concatUserPath(applicationsPath), id), &Application{})
	if err != nil {
		return nil, err
	}
	return result.(*Application), nil
}
1046270
func (s *DescribeSimulationJobOutput) SetRobotApplications(v []*RobotApplicationConfig) *DescribeSimulationJobOutput {
	s.RobotApplications = v
	return s
}
616046
func (s *CreateSimulationJobOutput) SetSimulationApplications(v []*SimulationApplicationConfig) *CreateSimulationJobOutput {
	s.SimulationApplications = v
	return s
}
1001109
func (o *Compute) SetApplications(v []*Application) *Compute {
	if o.Applications = v; o.Applications == nil {
		o.nullFields = append(o.nullFields, "Applications")
	}
	return o
}
1200579
func (st *State) WatchApplications() StringsWatcher {
	return newLifecycleWatcher(st, applicationsC, nil, isLocalID(st), nil)
}
608291
func (c *Client) ListApplicationsforServer(id string) (apps []Application, err error) {
	var appMap map[string]Application
	if err := c.get(`server/app_change_list?SUBID=`+id, &appMap); err != nil {
		return nil, err
	}

	for _, app := range appMap {
		apps = append(apps, app)
	}
	sort.Sort(applications(apps))
	return apps, nil
}
1269404
func (actor Actor) UpdateApplication(app Application) (Application, Warnings, error) {
	ccApp := ccv3.Application{
		GUID:                app.GUID,
		StackName:           app.StackName,
		LifecycleType:       app.LifecycleType,
		LifecycleBuildpacks: app.LifecycleBuildpacks,
	}

	updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccApp)
	if err != nil {
		return Application{}, Warnings(warnings), err
	}

	return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil
}
219064
func (api *RemoteRelationsAPI) RemoteApplications(entities params.Entities) (params.RemoteApplicationResults, error) {
	results := params.RemoteApplicationResults{
		Results: make([]params.RemoteApplicationResult, len(entities.Entities)),
	}
	one := func(entity params.Entity) (*params.RemoteApplication, error) {
		tag, err := names.ParseApplicationTag(entity.Tag)
		if err != nil {
			return nil, errors.Trace(err)
		}
		remoteApp, err := api.st.RemoteApplication(tag.Id())
		if err != nil {
			return nil, errors.Trace(err)
		}
		mac, err := remoteApp.Macaroon()
		if err != nil {
			return nil, errors.Trace(err)
		}
		return &params.RemoteApplication{
			Name:            remoteApp.Name(),
			OfferUUID:       remoteApp.OfferUUID(),
			Life:            params.Life(remoteApp.Life().String()),
			ModelUUID:       remoteApp.SourceModel().Id(),
			IsConsumerProxy: remoteApp.IsConsumerProxy(),
			Macaroon:        mac,
		}, nil
	}
	for i, entity := range entities.Entities {
		remoteApplication, err := one(entity)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		results.Results[i].Result = remoteApplication
	}
	return results, nil
}
459542
func (a *API) WatchApplications() (params.StringsWatchResult, error) {
	watch := a.state.WatchApplications()
	// Consume the initial event and forward it to the result.
	if changes, ok := <-watch.Changes(); ok {
		return params.StringsWatchResult{
			StringsWatcherId: a.resources.Register(watch),
			Changes:          changes,
		}, nil
	}
	return params.StringsWatchResult{}, watcher.EnsureErr(watch)
}
135800
func (s *ListApplicationsOutput) SetApplications(v []*ApplicationSummary) *ListApplicationsOutput {
	s.Applications = v
	return s
}
270163
func (c *Client) SetRemoteApplicationStatus(applicationName string, status status.Status, message string) error {
	args := params.SetStatus{Entities: []params.EntityStatusArgs{
		{Tag: names.NewApplicationTag(applicationName).String(), Status: status.String(), Info: message},
	}}
	var results params.ErrorResults
	err := c.facade.FacadeCall("SetRemoteApplicationsStatus", args, &results)
	if err != nil {
		return errors.Trace(err)
	}
	return results.OneError()
}