// DeployResources uploads the bytes for the given files to the server and
// creates pending resource metadata for the all resource mentioned in the
// metadata. It returns a map of resource name to pending resource IDs.
3794
func DeployResources(
	applicationID string,
	chID charmstore.CharmID,
	csMac *macaroon.Macaroon,
	filesAndRevisions map[string]string,
	resources map[string]charmresource.Meta,
	conn base.APICallCloser,
) (ids map[string]string, err error) {

	if len(filesAndRevisions)+len(resources) == 0 {
		// Nothing to upload.
		return nil, nil
	}

	client, err := NewAPIClient(conn)
	if err != nil {
		return nil, errors.Trace(err)
	}

	filenames := make(map[string]string)
	revisions := make(map[string]int)
	for name, val := range filesAndRevisions {
		rev, err := strconv.Atoi(val)
		if err != nil {
			filenames[name] = val
		} else {
			revisions[name] = rev
		}
	}

	ids, err = resourcecmd.DeployResources(resourcecmd.DeployResourcesArgs{
		ApplicationID:      applicationID,
		CharmID:            chID,
		CharmStoreMacaroon: csMac,
		ResourceValues:     filenames,
		Revisions:          revisions,
		ResourcesMeta:      resources,
		Client:             &deployClient{client},
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return ids, nil
}
1366595
func (s *AuthInfo) SetResources(v []*string) *AuthInfo {
	s.Resources = v
	return s
}
259972
func (s *UpdateClusterInput) SetResources(v *JobResource) *UpdateClusterInput {
	s.Resources = v
	return s
}
601314
func (f *Function) Deploy() error {
	f.Log.Debug("deploying")

	zip, err := f.ZipBytes()
	if err != nil {
		return err
	}

	if err := f.hookDeploy(); err != nil {
		return err
	}

	config, err := f.GetConfig()

	if e, ok := err.(awserr.Error); ok {
		if e.Code() == "ResourceNotFoundException" {
			return f.Create(zip)
		}
	}

	if err != nil {
		return err
	}

	if f.configChanged(config) {
		f.Log.Debug("config changed")
		return f.DeployConfigAndCode(zip)
	}

	f.Log.Info("config unchanged")
	return f.DeployCode(zip, config)
}
916224
func (c *Client) UploadResource(modelUUID string, res resource.Resource, r io.ReadSeeker) error {
	args := makeResourceArgs(res)
	args.Add("application", res.ApplicationID)
	err := c.resourcePost(modelUUID, args, r)
	return errors.Trace(err)
}
1294125
func (s *JobMetadata) SetResources(v *JobResource) *JobMetadata {
	s.Resources = v
	return s
}
1013572
func (s *noopFilesystemSource) ReleaseFilesystems(ctx environscontext.ProviderCallContext, filesystemIds []string) ([]error, error) {
	return make([]error, len(filesystemIds)), nil
}
129170
func (v *version) Deployments() DeploymentInformer {
	return &deploymentInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
111036
func (s *PutEventsRequestEntry) SetResources(v []*string) *PutEventsRequestEntry {
	s.Resources = v
	return s
}
35519
func (_m *ClientInterface) DeployTemplate(request servicetemplate.ServiceTemplateDeploymentRequest) ([]string, error) {
	ret := _m.Called(request)

	var r0 []string
	if rf, ok := ret.Get(0).(func(servicetemplate.ServiceTemplateDeploymentRequest) []string); ok {
		r0 = rf(request)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]string)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(servicetemplate.ServiceTemplateDeploymentRequest) error); ok {
		r1 = rf(request)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
747543
func (s *HandshakeResource) SetResources(v []*HandshakeResource) *HandshakeResource {
	s.Resources = v
	return s
}
1031519
func (m *MockAppsV1Interface) Deployments(arg0 string) v11.DeploymentInterface {
	ret := m.ctrl.Call(m, "Deployments", arg0)
	ret0, _ := ret[0].(v11.DeploymentInterface)
	return ret0
}
791164
func (s *Server) DeployTemplate(request servicetemplate.ServiceTemplateDeploymentRequest, response *[]string) error  {
	tenantIDs, err := s.f.DeployTemplate(s.context(), request.PoolID, request.TemplateID, request.DeploymentID)
	if err != nil {
		return err
	}
	*response = tenantIDs
	return nil
}
474633
func (s *UpdateJobInput) SetResources(v *JobResource) *UpdateJobInput {
	s.Resources = v
	return s
}
1253824
func (s *Server) generateServerResources(dir string) ([]*goResource, error) {
	var serverResources []*goResource

	resources := s.apiDef.Resources

	// sort the keys, so we have resource sorted by keys.
	// the generated code actually don't need it to be sorted.
	// but test fixture need it
	var keys []string
	for k := range resources {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	// create resource def
	var err error
	for _, endpoint := range keys {
		r := resources[endpoint]
		rd := resource.New(s.apiDef, &r, endpoint, true)
		pkgName := strings.ToLower(commons.NormalizeIdentifier(rd.Name))
		gr := newGoResource(&rd, pkgName)
		err = gr.generate(&r, endpoint, dir, s.libsRootURLs)
		if err != nil {
			return nil, err
		}
		serverResources = append(serverResources, gr)
	}
	return serverResources, nil
}
298273
func (api *APIv5) Deploy(args params.ApplicationsDeployV5) (params.ErrorResults, error) {
	noDefinedPolicy := ""
	var newArgs params.ApplicationsDeploy
	for _, value := range args.Applications {
		newArgs.Applications = append(newArgs.Applications, params.ApplicationDeploy{
			ApplicationName:  value.ApplicationName,
			Series:           value.Series,
			CharmURL:         value.CharmURL,
			Channel:          value.Channel,
			NumUnits:         value.NumUnits,
			Config:           value.Config,
			ConfigYAML:       value.ConfigYAML,
			Constraints:      value.Constraints,
			Placement:        value.Placement,
			Policy:           noDefinedPolicy,
			Storage:          value.Storage,
			AttachStorage:    value.AttachStorage,
			EndpointBindings: value.EndpointBindings,
			Resources:        value.Resources,
		})
	}
	return api.APIBase.Deploy(newArgs)
}
1306527
func (c *deployments) Create(deployment *v1.Deployment) (result *v1.Deployment, err error) {
	result = &v1.Deployment{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("deployments").
		Body(deployment).
		Do().
		Into(result)
	return
}