// FileURLByID returns direct url for files using FileId which you can get from File object
514072
func (b *Bot) FileURLByID(fileID string) (string, error) {
	f, err := b.FileByID(fileID)
	if err != nil {
		return "", err
	}
	return fmt.Sprintf("%s/file/bot%s/%s", b.URL, b.Token, f.FilePath), nil
}
792388
func AuthorizationURITenantID(url *url.URL) (string, error) {
	path := strings.TrimPrefix(url.Path, "/")
	if _, err := utils.UUIDFromString(path); err != nil {
		return "", errors.NotValidf("authorization_uri %q", url)
	}
	return path, nil
}
104078
func (s *DiskOfferingService) GetDiskOfferingByID(id string, opts ...OptionFunc) (*DiskOffering, int, error) {
	p := &ListDiskOfferingsParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListDiskOfferings(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.DiskOfferings[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for DiskOffering UUID: %s!", id)
}
288681
func (t *Trending) getUserIDBasedOnAvatarURL(avatarURL *url.URL) int {
	id := 0
	if avatarURL == nil {
		return id
	}

	re := regexp.MustCompile("u/([0-9]+)")
	if matches := re.FindStringSubmatch(avatarURL.Path); len(matches) >= 2 && len(matches[1]) > 0 {
		id, _ = strconv.Atoi(matches[1])
	}
	return id
}
153384
func (p *PullRequestComment) GetPullRequestReviewID() int64 {
	if p == nil || p.PullRequestReviewID == nil {
		return 0
	}
	return *p.PullRequestReviewID
}
943958
func (api *Client) SetCallRecodingEnabled(id string, enabled bool) error {
	_, err := api.UpdateCall(id, &UpdateCallData{RecordingEnabled: enabled})
	return err
}
572683
func PathToURI(path string) lsp.DocumentURI {
	path = filepath.ToSlash(path)
	parts := strings.SplitN(path, "/", 2)

	// If the first segment is a Windows drive letter, prefix with a slash and skip encoding
	head := parts[0]
	if head != "" {
		head = "/" + head
	}

	rest := ""
	if len(parts) > 1 {
		rest = "/" + parts[1]
	}

	return lsp.DocumentURI("file://" + head + rest)
}
1209025
func (api *API) LoadServerDvd(server_id string, dvd_id string) (*Server, error) {
	request := Identity{}
	request.Id = dvd_id
	result := new(Server)
	url := createUrl(api, serverPathSegment, server_id, "dvd")
	err := api.Client.Put(url, &request, &result, http.StatusAccepted)
	if err != nil {
		return nil, err
	}
	result.api = api
	result.decodeRaws()
	return result, nil
}
880215
func (e *Endpoint) ProxyID(l4 *policy.L4Filter) string {
	return policy.ProxyID(e.ID, l4.Ingress, string(l4.Protocol), uint16(l4.Port))
}
820754
func GetRequestID(ctx context.Context) (uint64, bool) {
	var (
		szID   []string
		szIDOK bool
	)

	// Prefer the incoming context, but look in both types.
	if md, ok := metadata.FromIncomingContext(ctx); ok {
		szID, szIDOK = md[RequestIDKey]
	} else if md, ok := metadata.FromOutgoingContext(ctx); ok {
		szID, szIDOK = md[RequestIDKey]
	}

	if szIDOK && len(szID) == 1 {
		if id, err := strconv.ParseUint(szID[0], 10, 64); err == nil {
			return id, true
		}
	}

	return 0, false
}
861831
func (c *Client) UnlockFileById(id string, force bool) error {
	unlockRes, _, err := c.client.Unlock(c.RemoteRef, c.Remote, id, force)
	if err != nil {
		return errors.Wrap(err, "api")
	}

	if len(unlockRes.Message) > 0 {
		if len(unlockRes.RequestID) > 0 {
			tracerx.Printf("Server Request ID: %s", unlockRes.RequestID)
		}
		return fmt.Errorf("Server unable to unlock: %s", unlockRes.Message)
	}

	if err := c.cache.RemoveById(id); err != nil {
		return fmt.Errorf("Error caching unlock information: %v", err)
	}

	if unlockRes.Lock != nil {
		abs, err := getAbsolutePath(unlockRes.Lock.Path)
		if err != nil {
			return errors.Wrap(err, "make lockpath absolute")
		}

		// Make non-writeable if required
		if c.SetLockableFilesReadOnly && c.IsFileLockable(unlockRes.Lock.Path) {
			return tools.SetFileWriteFlag(abs, false)
		}
	}

	return nil
}
276852
func (handler *UnroutedHandler) absFileURL(r *http.Request, id string) string {
	if handler.isBasePathAbs {
		return handler.basePath + id
	}

	// Read origin and protocol from request
	host, proto := getHostAndProtocol(r, handler.config.RespectForwardedHeaders)

	url := proto + "://" + host + handler.basePath + id

	return url
}
666683
func IDFromBytes(b []byte) (ID, error) {
	if _, err := mh.Cast(b); err != nil {
		return ID(""), err
	}
	return ID(b), nil
}
597038
func (s *NetworkACLService) GetNetworkACLListByID(id string, opts ...OptionFunc) (*NetworkACLList, int, error) {
	p := &ListNetworkACLListsParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListNetworkACLLists(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.NetworkACLLists[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for NetworkACLList UUID: %s!", id)
}
526311
func EscapeID(in string) string {
	var buf bytes.Buffer
	WriteEscapeID(&buf, in)
	return buf.String()
}
847610
func CustomNameID(file *descriptor.FileDescriptorProto) {

	f := func(field *descriptor.FieldDescriptorProto) {
		// Skip if [(gogoproto.customname) = "..."] has already been set.
		if gogoproto.IsCustomName(field) {
			return
		}
		// Skip if embedded
		if gogoproto.IsEmbed(field) {
			return
		}
		if field.OneofIndex != nil {
			return
		}
		fieldName := generator.CamelCase(*field.Name)
		switch {
		case *field.Name == "id":
			// id -> ID
			fieldName = "ID"
		case strings.HasPrefix(*field.Name, "id_"):
			// id_some -> IDSome
			fieldName = "ID" + fieldName[2:]
		case strings.HasSuffix(*field.Name, "_id"):
			// some_id -> SomeID
			fieldName = fieldName[:len(fieldName)-2] + "ID"
		case strings.HasSuffix(*field.Name, "_ids"):
			// some_ids -> SomeIDs
			fieldName = fieldName[:len(fieldName)-3] + "IDs"
		default:
			return
		}
		if field.Options == nil {
			field.Options = &descriptor.FieldOptions{}
		}
		if err := proto.SetExtension(field.Options, gogoproto.E_Customname, &fieldName); err != nil {
			panic(err)
		}
	}

	// Iterate through all fields in file
	vanity.ForEachFieldExcludingExtensions(file.MessageType, f)
}
1020744
func UriToRealPath(uri lsp.DocumentURI) string {
	path := UriToPath(uri)

	if regDriveLetter.MatchString(path) {
		// remove the leading slash if it starts with a drive letter
		// and convert to back slashes
		path = filepath.FromSlash(path[1:])
	}

	return path
}