// CreateLink creates a new child Link under the Domain
11853
func (o *Domain) CreateLink(child *Link) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
1219359
func createLinkEntry(origURL string, maxEntries int, lastEntry string) (string, error) {
	calledURL, err := url.Parse(origURL)
	if err != nil {
		return "", err
	}

	v := url.Values{}
	v.Add("n", strconv.Itoa(maxEntries))
	v.Add("last", lastEntry)

	calledURL.RawQuery = v.Encode()

	calledURL.Fragment = ""
	urlStr := fmt.Sprintf("<%s>; rel=\"next\"", calledURL.String())

	return urlStr, nil
}
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
}
652211
func (c *Client) createURL(e ...Endpoint) *url.URL {
	mu := *c.url
	for _, f := range e {
		f(&mu)
	}
	return &mu
}
1235311
func (c ConstantSet) Link(scope Scope, t TypeSpec) (ConstantValue, error) {
	s, ok := RootTypeSpec(t).(*SetSpec)
	if !ok {
		return nil, constantValueCastError{Value: c, Type: t}
	}

	// TODO(abg): Track whether things are linked so that we don't re-link here
	// TODO(abg): Fail for duplicates
	values := make([]ConstantValue, len(c))
	for i, v := range c {
		value, err := v.Link(scope, s.ValueSpec)
		if err != nil {
			return nil, err
		}
		values[i] = value
	}

	return ConstantSet(values), nil
}
573492
func (as ArgsSpec) Link(scope Scope) error {
	return FieldGroup(as).Link(scope)
}
1186260
func (c *TokenController) Link(ctx *app.LinkTokenContext) error {
	if ctx.For == "" {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("for", "").Expected("git or OpenShift resource URL"))
	}
	currentIdentity, err := c.app.UserService().ContextIdentityIfExists(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	var redirectURL string
	if ctx.Redirect == nil {
		redirectURL = ctx.RequestData.Header.Get("Referer")
		if redirectURL == "" {
			return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("redirect", "empty").Expected("redirect param or Referer header should be specified"))
		}
	} else {
		redirectURL = *ctx.Redirect
	}

	redirectLocation, err := c.app.LinkService().ProviderLocation(ctx, ctx.RequestData, currentIdentity.String(), ctx.For, redirectURL)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	locationPayload := &app.RedirectLocation{RedirectLocation: redirectLocation}
	return ctx.OK(locationPayload)
}
858145
func (b BuilderID) SelfLink(project string) string {
	return model.BuilderIDLink(string(b), project)
}
237982
func (a *Artist) Link() *Link {
	sp_link := C.sp_link_create_from_artist(a.sp_artist)
	return newLink(a.session, sp_link, false)
}
597771
func (c *controllerAPI) CreateSink(ctx context.Context, w http.ResponseWriter, req *http.Request) {
	var sink ct.Sink
	if err := httphelper.DecodeJSON(req, &sink); err != nil {
		respondWithError(w, err)
		return
	}

	if err := schema.Validate(&sink); err != nil {
		respondWithError(w, err)
		return
	}

	if err := c.sinkRepo.Add(&sink); err != nil {
		respondWithError(w, err)
		return
	}
	httphelper.JSON(w, 200, &sink)
}
291333
func (c CurieHandle) AddNewLink(rel Relation, href string) {
	rel = Relation(c.Name) + ":" + rel
	c.Resource.AddLink(rel, NewLink(href, nil))
}
939804
func (i *HTTPInstaller) link(from string) error {
	debug("symlinking %s to %s", from, i.Path())
	return os.Symlink(from, i.Path())
}
299352
func (o *Me) CreateNSGateway(child *NSGateway) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
267055
func (c Context) AddLink(link string) string {
	if c.responseHeader == nil {
		return ""
	}
	c.responseHeader.Add("Link", link)
	return ""
}
72445
func NewLink(href string, attrs ...LinkAttr) Link {
	l := make(Link)

	l["href"] = href

	for _, attr := range attrs {
		for k, v := range attr {
			l[k] = v
		}
	}

	return l
}
333186
func NewPathLinkMetadata(Url string, Visibility *Visibility, Path string) *PathLinkMetadata {
	s := new(PathLinkMetadata)
	s.Url = Url
	s.Visibility = Visibility
	s.Path = Path
	return s
}
1103577
func (f *FingerprintResponse) AddLink(name, value string) {
	// initialize Links if it has not been already
	if f.Links == nil {
		f.Links = make(map[string]string, 0)
	}

	f.Links[name] = value
}