// CreateOrUpdateSymlink ...
519204
func CreateOrUpdateSymlink(symlinkTargetPath, symlinkLocationPath string) error {
	fileInfo, isExists, err := pathutil.PathCheckAndInfos(symlinkLocationPath)
	if err != nil {
		return fmt.Errorf("Failed to check Symlink status (at: %s), error: %s", symlinkLocationPath, err)
	}
	isSymlinkAlreadyInPlace := false
	if isExists && fileInfo.Mode()&os.ModeSymlink != 0 {
		log.Debug(" Symlink already exists")
		originPth, err := os.Readlink(symlinkLocationPath)
		if err != nil {
			return fmt.Errorf("Symlink found (at: %s), but failed to open: %s", symlinkLocationPath, err)
		}

		if originPth == symlinkTargetPath {
			isSymlinkAlreadyInPlace = true
		} else {
			// remove
			log.Warningf("Symlink already exists (at: %s), but target (%s) is not the current one (%s)", symlinkLocationPath, originPth, symlinkTargetPath)
			log.Warning("Removing and re-creating the symlink ...")
			if err := os.Remove(symlinkLocationPath); err != nil {
				return fmt.Errorf("Failed to remove Symlink (at: %s), error: %s", symlinkLocationPath, err)
			}
		}
	}

	if !isSymlinkAlreadyInPlace {
		log.Debug(" Creating symlink ...")
		// create the parent directory
		if err := os.MkdirAll(filepath.Dir(symlinkLocationPath), 0777); err != nil {
			return fmt.Errorf("Failed to create base directory for symlink into: %s", symlinkLocationPath)
		}
		// create symlink
		if err := os.Symlink(symlinkTargetPath, symlinkLocationPath); err != nil {
			return fmt.Errorf("Failed to create symlink from project directory (%s) into gows Workspace directory (%s), error: %s", symlinkTargetPath, symlinkLocationPath, err)
		}
	}

	return nil
}
1017325
func (i *Index) PartialUpdateObject(object interface{}, opts ...interface{}) (res UpdateTaskRes, err error) {
	objectID, ok := getObjectID(object)
	if !ok {
		err = errs.ErrMissingObjectID
		res.wait = noWait
		return
	}

	opts = opt.InsertExtraURLParam(
		opts,
		"createIfNotExists",
		iopt.ExtractCreateIfNotExists(opts...).Get(),
	)

	path := i.path("/" + url.QueryEscape(objectID) + "/partial")
	err = i.transport.Request(&res, http.MethodPost, path, object, call.Write, opts...)
	res.wait = i.WaitTask
	return
}
471674
func (s *DomainService) NewUpdateDomainParams(id string) *UpdateDomainParams {
	p := &UpdateDomainParams{}
	p.p = make(map[string]interface{})
	p.p["id"] = id
	return p
}
414959
func (r ResourceEventHandlerFuncs) OnUpdate(oldObj, newObj interface{}) {
	if r.UpdateFunc != nil {
		r.UpdateFunc(oldObj, newObj)
	}
}
826708
func (s *HostService) NewUpdateHostParams(id string) *UpdateHostParams {
	p := &UpdateHostParams{}
	p.p = make(map[string]interface{})
	p.p["id"] = id
	return p
}
652954
func (s *UpdateLinkAttributesInput) SetAttributeUpdates(v []*LinkAttributeUpdate) *UpdateLinkAttributesInput {
	s.AttributeUpdates = v
	return s
}
568277
func (r Network_Storage_Backup_Evault) CreateOrUpdateLunId(lunId *int) (resp datatypes.Network_Storage_Property, err error) {
	params := []interface{}{
		lunId,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Storage_Backup_Evault", "createOrUpdateLunId", params, &r.Options, &resp)
	return
}
11853
func (o *Domain) CreateLink(child *Link) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
3973
func (s *HypervisorService) NewUpdateHypervisorCapabilitiesParams() *UpdateHypervisorCapabilitiesParams {
	p := &UpdateHypervisorCapabilitiesParams{}
	p.p = make(map[string]interface{})
	return p
}
703018
func (az *Cloud) CreateOrUpdateRoute(route network.Route) error {
	if az.Config.shouldOmitCloudProviderBackoff() {
		ctx, cancel := getContextWithCancel()
		defer cancel()

		resp, err := az.RoutesClient.CreateOrUpdate(ctx, az.RouteTableResourceGroup, az.RouteTableName, *route.Name, route)
		klog.V(10).Infof("RoutesClient.CreateOrUpdate(%s): end", *route.Name)
		return az.processHTTPResponse(nil, "", resp, err)
	}

	return az.createOrUpdateRouteWithRetry(route)
}
199924
func NewSymlinkInfo(Target string) *SymlinkInfo {
	s := new(SymlinkInfo)
	s.Target = Target
	return s
}
827143
func (s *DiskOfferingService) NewUpdateDiskOfferingParams(id string) *UpdateDiskOfferingParams {
	p := &UpdateDiskOfferingParams{}
	p.p = make(map[string]interface{})
	p.p["id"] = id
	return p
}
1216600
func (p *PartitionedMemoryIdx) AddOrUpdate(mkey schema.MKey, data *schema.MetricData, partition int32) (idx.Archive, int32, bool) {
	return p.Partition[partition].AddOrUpdate(mkey, data, partition)
}
410491
func (m *linkMechanismManager) UpdateLink(context *LinkManagerContext) (err error) {
	link := new(LinkManagerContext)

	update := func(fn func() error) error {
		return m.BaseMechanismManager.Update(
			LinkModel, link, fn,
		)
	}

	pre := func(port LinkPort) error {
		linkContext, err := m.linkContext(port)
		if err != nil {
			return err
		}

		err = m.do(func(llmech LinkMechanism) error {
			return llmech.UpdateLinkPreCommit(linkContext)
		})

		if err != nil {
			log.ErrorLog("link/UPDATE_LINK_PRECOMMIT",
				"Failed to update link configuration: ", err)
		}

		return err
	}

	post := func(port LinkPort) error {
		linkContext, err := m.linkContext(port)
		if err != nil {
			return err
		}

		err = m.do(func(llmech LinkMechanism) error {
			return llmech.UpdateLinkPostCommit(linkContext)
		})

		if err != nil {
			log.ErrorLog("link/UPDATE_LINK_POSTCOMMIT",
				"Failed to update link configuration: ", err)
		}

		return err
	}

	m.lock.RLock()
	defer m.lock.RUnlock()

	return update(func() error {
		_, err := m.Driver()
		if err != nil && len(link.Ports) != 0 {
			log.ErrorLog("link/UPDATE_LINK",
				"Driver not found, but ports need to be updated")
			return ErrLinkNotInitialized
		}

		for _, port := range context.Ports {
			port = link.Port(port.Port)
			blank := LinkPort{}

			// Skip blank ports
			if port == blank {
				continue
			}

			// Update pre-commit
			if err := pre(port); err != nil {
				log.ErrorLog("link/UPDATE_LINK",
					"Link layer delete pre-commit failed: ", err)
				return err
			}
		}

		// Set new link layer driver
		err = m.SetDriver(context.Driver)
		if err != nil {
			return err
		}

		// Update driver configuration
		link.Driver = context.Driver

		for _, port := range context.Ports {
			// Update  post-commit
			if err := post(port); err != nil {
				log.ErrorLog("link/UPDATE_LINK",
					"Link layer update pre-commit failed: ", err)
				return err
			}

			// Update link layer port configuration
			link.SetPort(port)
		}

		return nil
	})
}
716700
func (client ResourcesClient) CreateOrUpdateByID(ctx context.Context, resourceID string, parameters resources.GenericResource, apiVersion string) (result resources.CreateOrUpdateByIDFuture, err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdateByID")
		defer func() {
			sc := -1
			if result.Response() != nil {
				sc = result.Response().StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	if err := validation.Validate([]validation.Validation{
		{TargetValue: parameters,
			Constraints: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Null, Rule: false,
				Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
		return result, validation.NewError("resources.Client", "CreateOrUpdateByID", err.Error())
	}

	req, err := client.CreateOrUpdateByIDPreparer(ctx, resourceID, parameters)
	if err != nil {
		err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdateByID", nil, "Failure preparing request")
		return
	}
	setAPIVersion(req, apiVersion)

	result, err = client.CreateOrUpdateByIDSender(req)
	if err != nil {
		err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdateByID", result.Response(), "Failure sending request")
		return
	}

	return
}
395307
func (s *GuestOSService) NewUpdateGuestOsMappingParams(id string, osnameforhypervisor string) *UpdateGuestOsMappingParams {
	p := &UpdateGuestOsMappingParams{}
	p.p = make(map[string]interface{})
	p.p["id"] = id
	p.p["osnameforhypervisor"] = osnameforhypervisor
	return p
}
490285
func (p *Project) CreateOrUpdateAlias(alias, version string) error {
	p.Log.Debugf("updating %d functions", len(p.Functions))

	sem := make(semaphore.Semaphore, p.Concurrency)
	errs := make(chan error)

	go func() {
		for _, fn := range p.Functions {
			fn := fn
			sem.Acquire()

			go func() {
				defer sem.Release()

				version, err := fn.GetVersionFromAlias(version)
				if err != nil {
					err = fmt.Errorf("function %s: %s", fn.Name, err)
				}

				err = fn.CreateOrUpdateAlias(alias, version)
				if err != nil {
					err = fmt.Errorf("function %s: %s", fn.Name, err)
				}

				errs <- err
			}()
		}

		sem.Wait()
		close(errs)
	}()

	for err := range errs {
		if err != nil {
			return err
		}
	}

	return nil
}