// addApplication deploys an application with no units.
508262
func (h *bundleHandler) addApplication(change *bundlechanges.AddApplicationChange) error {
	// TODO: add verbose output for details
	if h.dryRun {
		return nil
	}

	p := change.Params
	cURL, err := charm.ParseURL(resolve(p.Charm, h.results))
	if err != nil {
		return errors.Trace(err)
	}

	chID := charmstore.CharmID{
		URL:     cURL,
		Channel: h.channels[cURL],
	}
	macaroon := h.macaroons[cURL]

	h.results[change.Id()] = p.Application
	ch := chID.URL.String()

	// Handle application configuration.
	configYAML := ""
	if len(p.Options) > 0 {
		config, err := yaml.Marshal(map[string]map[string]interface{}{p.Application: p.Options})
		if err != nil {
			return errors.Annotatef(err, "cannot marshal options for application %q", p.Application)
		}
		configYAML = string(config)
	}
	// Handle application constraints.
	cons, err := constraints.Parse(p.Constraints)
	if err != nil {
		// This should never happen, as the bundle is already verified.
		return errors.Annotate(err, "invalid constraints for application")
	}
	storageConstraints := h.bundleStorage[p.Application]
	if len(p.Storage) > 0 {
		if storageConstraints == nil {
			storageConstraints = make(map[string]storage.Constraints)
		}
		for k, v := range p.Storage {
			if _, ok := storageConstraints[k]; ok {
				// Storage constraints overridden
				// on the command line.
				continue
			}
			cons, err := storage.ParseConstraints(v)
			if err != nil {
				return errors.Annotate(err, "invalid storage constraints")
			}
			storageConstraints[k] = cons
		}
	}
	deviceConstraints := h.bundleDevices[p.Application]
	if len(p.Devices) > 0 {
		if deviceConstraints == nil {
			deviceConstraints = make(map[string]devices.Constraints)
		}
		for k, v := range p.Devices {
			if _, ok := deviceConstraints[k]; ok {
				// Device constraints overridden
				// on the command line.
				continue
			}
			cons, err := devices.ParseConstraints(v)
			if err != nil {
				return errors.Annotate(err, "invalid device constraints")
			}
			deviceConstraints[k] = cons
		}
	}
	charmInfo, err := h.api.CharmInfo(ch)
	if err != nil {
		return errors.Trace(err)
	}
	resources := h.makeResourceMap(charmInfo.Meta.Resources, p.Resources, p.LocalResources)

	if err := lxdprofile.ValidateLXDProfile(lxdCharmInfoProfiler{
		CharmInfo: charmInfo,
	}); err != nil {
		return errors.Trace(err)
	}

	resNames2IDs, err := resourceadapters.DeployResources(
		p.Application,
		chID,
		macaroon,
		resources,
		charmInfo.Meta.Resources,
		h.api,
	)
	if err != nil {
		return errors.Trace(err)
	}

	// Figure out what series we need to deploy with.
	supportedSeries := charmInfo.Meta.Series
	if len(supportedSeries) == 0 && chID.URL.Series != "" {
		supportedSeries = []string{chID.URL.Series}
	}
	selector := seriesSelector{
		seriesFlag:      p.Series,
		charmURLSeries:  chID.URL.Series,
		supportedSeries: supportedSeries,
		conf:            h.modelConfig,
		fromBundle:      true,
	}
	series, err := selector.charmSeries()
	if err != nil {
		return errors.Trace(err)
	}

	// Only Kubernetes bundles send the unit count and placement with the deploy API call.
	numUnits := 0
	var placement []*instance.Placement
	if h.data.Type == "kubernetes" {
		numUnits = p.NumUnits
	}
	// Deploy the application.
	if err := h.api.Deploy(application.DeployArgs{
		CharmID:          chID,
		Cons:             cons,
		ApplicationName:  p.Application,
		Series:           series,
		NumUnits:         numUnits,
		Placement:        placement,
		ConfigYAML:       configYAML,
		Storage:          storageConstraints,
		Devices:          deviceConstraints,
		Resources:        resNames2IDs,
		EndpointBindings: p.EndpointBindings,
	}); err != nil {
		return errors.Annotatef(err, "cannot deploy application %q", p.Application)
	}
	h.writeAddedResources(resNames2IDs)

	return nil
}
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
}
820683
func (_m *Marathon) CreateApplication(application *marathon.Application) (*marathon.Application, error) {
	ret := _m.Called(application)

	var r0 *marathon.Application
	if rf, ok := ret.Get(0).(func(*marathon.Application) *marathon.Application); ok {
		r0 = rf(application)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*marathon.Application)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(*marathon.Application) error); ok {
		r1 = rf(application)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1306244
func (s *APNSVoipSandboxChannelResponse) SetApplicationId(v string) *APNSVoipSandboxChannelResponse {
	s.ApplicationId = &v
	return s
}
324346
func (s *Version) SetApplicationId(v string) *Version {
	s.ApplicationId = &v
	return s
}
98685
func (s *GetDiscoverySummaryOutput) SetApplications(v int64) *GetDiscoverySummaryOutput {
	s.Applications = &v
	return s
}
1269516
func (s *GetImportJobsInput) SetApplicationId(v string) *GetImportJobsInput {
	s.ApplicationId = &v
	return s
}
1077984
func (s *UpdateApnsVoipChannelInput) SetApplicationId(v string) *UpdateApnsVoipChannelInput {
	s.ApplicationId = &v
	return s
}
233100
func (s *CreateDeploymentGroupInput) SetApplicationName(v string) *CreateDeploymentGroupInput {
	s.ApplicationName = &v
	return s
}
915337
func (s *GetApnsVoipChannelInput) SetApplicationId(v string) *GetApnsVoipChannelInput {
	s.ApplicationId = &v
	return s
}
71907
func (s *CampaignResponse) SetApplicationId(v string) *CampaignResponse {
	s.ApplicationId = &v
	return s
}
1151395
func (s *SMSChannelResponse) SetApplicationId(v string) *SMSChannelResponse {
	s.ApplicationId = &v
	return s
}
500260
func (s *MessageResponse) SetApplicationId(v string) *MessageResponse {
	s.ApplicationId = &v
	return s
}
259172
func (s *GetCloudFormationTemplateInput) SetApplicationId(v string) *GetCloudFormationTemplateInput {
	s.ApplicationId = &v
	return s
}
1308261
func (s *GetSmsChannelInput) SetApplicationId(v string) *GetSmsChannelInput {
	s.ApplicationId = &v
	return s
}
422197
func (s *SegmentResponse) SetApplicationId(v string) *SegmentResponse {
	s.ApplicationId = &v
	return s
}
714858
func (o *Enterprise) CreateApplication(child *Application) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}