// ChangeApplicationofBareMetalServer changes the bare metal server to a different application.
499391
func (c *Client) ChangeApplicationofBareMetalServer(id string, appID string) error {
	values := url.Values{
		"SUBID": {id},
		"APPID": {appID},
	}

	return c.post(`baremetal/app_change`, values, nil)
}
390258
func (s *EnvironmentDescription) SetApplicationName(v string) *EnvironmentDescription {
	s.ApplicationName = &v
	return s
}
212817
func (s *ResourceQuotas) SetApplicationVersionQuota(v *ResourceQuota) *ResourceQuotas {
	s.ApplicationVersionQuota = v
	return s
}
321014
func (s *DeploymentInfo) SetApplicationName(v string) *DeploymentInfo {
	s.ApplicationName = &v
	return s
}
619477
func DeployApplication(st ApplicationDeployer, args DeployApplicationParams) (Application, error) {
	charmConfig, err := args.Charm.Config().ValidateSettings(args.CharmConfig)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if args.Charm.Meta().Subordinate {
		if args.NumUnits != 0 {
			return nil, fmt.Errorf("subordinate application must be deployed without units")
		}
		if !constraints.IsEmpty(&args.Constraints) {
			return nil, fmt.Errorf("subordinate application must be deployed without constraints")
		}
	}
	// TODO(fwereade): transactional State.AddApplication including settings, constraints
	// (minimumUnitCount, initialMachineIds?).

	effectiveBindings, err := getEffectiveBindingsForCharmMeta(args.Charm.Meta(), args.EndpointBindings)
	if err != nil {
		return nil, errors.Trace(err)
	}

	asa := state.AddApplicationArgs{
		Name:              args.ApplicationName,
		Series:            args.Series,
		Charm:             args.Charm,
		Channel:           args.Channel,
		Storage:           stateStorageConstraints(args.Storage),
		Devices:           stateDeviceConstraints(args.Devices),
		AttachStorage:     args.AttachStorage,
		ApplicationConfig: args.ApplicationConfig,
		CharmConfig:       charmConfig,
		NumUnits:          args.NumUnits,
		Placement:         args.Placement,
		Resources:         args.Resources,
		EndpointBindings:  effectiveBindings,
	}

	if !args.Charm.Meta().Subordinate {
		asa.Constraints = args.Constraints
	}
	return st.AddApplication(asa)
}
375013
func (s *BatchGetDeploymentGroupsInput) SetApplicationName(v string) *BatchGetDeploymentGroupsInput {
	s.ApplicationName = &v
	return s
}
852685
func (s *ApplicationDetail) SetApplicationARN(v string) *ApplicationDetail {
	s.ApplicationARN = &v
	return s
}
1194041
func (s *ApplicationSummary) SetApplicationName(v string) *ApplicationSummary {
	s.ApplicationName = &v
	return s
}
754639
func (s *UpdateApplicationInput) SetApplicationConfigurationUpdate(v *ApplicationConfigurationUpdate) *UpdateApplicationInput {
	s.ApplicationConfigurationUpdate = v
	return s
}
685449
func (s *SystemVMService) ChangeServiceForSystemVm(p *ChangeServiceForSystemVmParams) (*ChangeServiceForSystemVmResponse, error) {
	resp, err := s.cs.newRequest("changeServiceForSystemVm", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ChangeServiceForSystemVmResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
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
}
158908
func (c *Client) RenameBareMetalServer(id, name string) error {
	values := url.Values{
		"SUBID": {id},
		"label": {name},
	}

	return c.post(`baremetal/label_set`, values, nil)
}
104025
func (s *UpdateEnvironmentInput) SetApplicationName(v string) *UpdateEnvironmentInput {
	s.ApplicationName = &v
	return s
}
798387
func (s *DeploymentGroupInfo) SetApplicationName(v string) *DeploymentGroupInfo {
	s.ApplicationName = &v
	return s
}
1305003
func (s *BatchGetApplicationsOutput) SetApplicationsInfo(v []*ApplicationInfo) *BatchGetApplicationsOutput {
	s.ApplicationsInfo = v
	return s
}
475585
func (client *Client) UpdateApplicationApplyManifest(appGUID string, rawManifest []byte) (JobURL, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.PostApplicationActionApplyManifest,
		URIParams:   map[string]string{"app_guid": appGUID},
		Body:        bytes.NewReader(rawManifest),
	})

	if err != nil {
		return "", nil, err
	}

	request.Header.Set("Content-Type", "application/x-yaml")

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

	return JobURL(response.ResourceLocationURL), response.Warnings, err
}
217896
func (actor Actor) ApplyApplicationManifest(parser ManifestParser, spaceGUID string) (Warnings, error) {
	var allWarnings Warnings

	for _, appName := range parser.AppNames() {
		rawManifest, err := parser.RawAppManifest(appName)
		if err != nil {
			return allWarnings, err
		}

		app, getAppWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)

		allWarnings = append(allWarnings, getAppWarnings...)
		if err != nil {
			return allWarnings, err
		}

		applyManifestWarnings, err := actor.SetApplicationManifest(app.GUID, rawManifest)
		allWarnings = append(allWarnings, applyManifestWarnings...)
		if err != nil {
			return allWarnings, err
		}
	}

	return allWarnings, nil
}