// Profile gets the user profile of the user that is logged in
499566
func (a *Account) Profile() (user Profile, err error) {
	err = a.get(a.auth, "/api/v2/users/me", &user)
	if err != nil {
		return user, fmt.Errorf("Could not get user profile: %s", err)
	}

	return user, nil
}
1132119
func Load(profile string, configPaths ...string) *Profile {
	config := viper.New()
	if len(configPaths) > 0 {
		for _, p := range configPaths {
			config.AddConfigPath(p)
		}
		config.SetConfigName(configName)
	} else {
		cf.InitViper(config, configName)
	}

	// For environment variables
	config.SetEnvPrefix(Prefix)
	config.AutomaticEnv()

	// This replacer allows substitution within the particular profile without
	// having to fully qualify the name
	replacer := strings.NewReplacer(strings.ToUpper(fmt.Sprintf("profiles.%s.", profile)), "", ".", "_")
	config.SetEnvKeyReplacer(replacer)

	err := config.ReadInConfig()
	if err != nil {
		logger.Panic("Error reading configuration: ", err)
	}
	logger.Debugf("Using config file: %s", config.ConfigFileUsed())

	var uconf TopLevel
	err = viperutil.EnhancedExactUnmarshal(config, &uconf)
	if err != nil {
		logger.Panic("Error unmarshaling config into struct: ", err)
	}

	result, ok := uconf.Profiles[profile]
	if !ok {
		logger.Panic("Could not find profile: ", profile)
	}

	result.completeInitialization(filepath.Dir(config.ConfigFileUsed()))

	logger.Infof("Loaded configuration: %s", config.ConfigFileUsed())

	return result
}
849518
func (e Endpoints) PatchProfile(ctx context.Context, id string, p Profile) error {
	request := patchProfileRequest{ID: id, Profile: p}
	response, err := e.PatchProfileEndpoint(ctx, request)
	if err != nil {
		return err
	}
	resp := response.(patchProfileResponse)
	return resp.Err
}
1206769
func (s *Server) HasProfile(name string) (bool, error) {
	profiles, err := s.GetProfileNames()
	if err != nil {
		return false, errors.Trace(err)
	}
	for _, profile := range profiles {
		if profile == name {
			return true, nil
		}
	}
	return false, nil
}
914254
func Profile(w http.ResponseWriter, r *http.Request) {
	sec, _ := strconv.ParseInt(r.FormValue("seconds"), 10, 64)
	if sec == 0 {
		sec = 30
	}

	// Set Content Type assuming StartCPUProfile will work,
	// because if it does it starts writing.
	w.Header().Set("Content-Type", "application/octet-stream")
	if err := pprof.StartCPUProfile(w); err != nil {
		// StartCPUProfile failed, so no writes yet.
		// Can change header back to text content
		// and send error code.
		w.Header().Set("Content-Type", "text/plain; charset=utf-8")
		w.WriteHeader(http.StatusInternalServerError)
		fmt.Fprintf(w, "Could not enable CPU profiling: %s\n", err)
		return
	}
	sleep(w, time.Duration(sec)*time.Second)
	pprof.StopCPUProfile()
}
921923
func ProfilePath() (string, error) {
	if cfgDir := os.Getenv("AZURE_CONFIG_DIR"); cfgDir != "" {
		return filepath.Join(cfgDir, azureProfileJSON), nil
	}
	return homedir.Expand("~/.azure/" + azureProfileJSON)
}
825573
func WithProfile(profile string) EnrollmentOption {
	return func(o *enrollmentOptions) error {
		o.profile = profile
		return nil
	}
}
970550
func WithProfile(profile string) oci.SpecOpts {
	return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
		s.Process.ApparmorProfile = profile
		return nil
	}
}
1119751
func (s profileService) FetchProfile(profileUUID string) (*Profile, error) {
	var response Profile
	req, err := s.client.NewRequest("GET", defineProfilePath, nil)
	if err != nil {
		return nil, err
	}
	query := req.URL.Query()
	query.Add("profile_uuid", profileUUID)
	req.URL.RawQuery = query.Encode()
	err = s.client.Do(req, &response)
	if err != nil {
		return nil, err
	}
	return &response, nil
}
47936
func (provider *GitlabProvider) GetUser(creds *common.Credentials) (common.User, error) {

	profileData, err := provider.Get(creds, gitlabEndpointProfile)

	if err != nil {
		return nil, err
	}

	// build user
	user := NewUser(profileData, creds, provider)

	return user, nil
}
253400
func profile(profFile string, dieAfter time.Duration, readyCh <-chan struct{}) {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, os.Interrupt)
	go func() {
		if readyCh != nil {
			<-readyCh
		}
		start := time.Now()
		initialUserTime, initialSysTime := getRusage()
		packetsInitiallySent, packetsInitiallyReceived := MQTT.GetStats()

		f, err := os.Create(profFile)
		if err != nil {
			Error.Fatalf("error creating profiling file: %s", err)
		}
		pprof.StartCPUProfile(f)

		// TBD: add timer
		var dieCh <-chan time.Time = nil
		if dieAfter > 0 {
			dieCh = time.After(dieAfter)
		}
		select {
		case <-ch:
		case <-dieCh:
		}
		newUserTime, newSysTime := getRusage()
		elapsed := time.Since(start)
		if elapsed == 0 {
			fmt.Fprintln(os.Stderr, "oops, no time elapsed?")
			return
		}
		elapsedUserTime := newUserTime - initialUserTime
		elapsedSysTime := newSysTime - initialSysTime
		elapsedCpuTime := elapsedUserTime + elapsedSysTime
		cpuLoadUser := float64(elapsedUserTime) * 100.0 / float64(elapsed)
		cpuLoadSys := float64(elapsedSysTime) * 100.0 / float64(elapsed)
		cpuLoad := float64(elapsedCpuTime) * 100.0 / float64(elapsed)

		newPacketsSent, newPacketsReceived := MQTT.GetStats()
		packetsSent := newPacketsSent - packetsInitiallySent
		packetsReceived := newPacketsReceived - packetsInitiallyReceived
		if packetsSent > 0 || packetsReceived > 0 {
			packetsSentPerSecond := float64(packetsSent) * float64(time.Second) /
				float64(elapsed)
			packetsReceivedPerSecond := float64(packetsReceived) * float64(time.Second) /
				float64(elapsed)
			packetsSentPerCpuSecond := float64(packetsSent) * float64(time.Second) /
				float64(elapsedCpuTime)
			packetsReceivedPerCpuSecond := float64(packetsReceived) * float64(time.Second) /
				float64(elapsedCpuTime)

			fmt.Printf("\n*** %d packets sent (%.2f per sec, %.2f per cpu sec), "+
				"%d packets received (%.2f per sec, %.2f per cpu sec)\n",
				packetsSent, packetsSentPerSecond, packetsSentPerCpuSecond,
				packetsReceived, packetsReceivedPerSecond, packetsReceivedPerCpuSecond)
		}

		fmt.Printf("*** %.2f seconds elapsed, %.2f user, %.2f sys\n",
			float64(elapsed)/float64(time.Second),
			float64(elapsedUserTime)/float64(time.Second),
			float64(elapsedSysTime)/float64(time.Second))
		fmt.Printf("*** %.2f%% CPU load, %.2f%% user, %.2f%% sys\n",
			cpuLoad, cpuLoadUser, cpuLoadSys)
		pprof.StopCPUProfile()
		os.Exit(130)
	}()
}
1220190
func (p profile) fullname() string {
	fname := strings.TrimSpace(p.FirstName + " " + p.LastName)
	if fname == "" {
		return p.Email
	}

	return fname
}
528610
func (r Layout_Profile_Containers) GetLayoutProfile() (resp datatypes.Layout_Profile, err error) {
	err = r.Session.DoRequest("SoftLayer_Layout_Profile_Containers", "getLayoutProfile", nil, &r.Options, &resp)
	return
}
704631
func (r *rest) Delete(c *gin.Context) {
	if err := r.service.Remove(c.Param("profileId")); err != nil {
		c.JSON(apihelper.BuildResponseError(err))
	} else {
		c.JSON(http.StatusOK, gin.H{"message": "profile has been deleted successfully"})
	}
}
985825
func (provider *DefaultIdentityProvider) Profile(ctx context.Context, token oauth2.Token) (*UserProfile, error) {
	body, err := provider.UserProfilePayload(ctx, token)
	if err != nil {
		return nil, err
	}
	var u UserProfile
	var idpResponse IdentityProviderResponse
	err = json.Unmarshal(body, &idpResponse)
	if err != nil {
		return nil, err
	}

	u = UserProfile{
		Username:      idpResponse.Username,
		GivenName:     idpResponse.GivenName,
		FamilyName:    idpResponse.FamilyName,
		Email:         idpResponse.Email,
		EmailVerified: idpResponse.EmailVerified,
		Company:       idpResponse.Company,
		Approved:      idpResponse.Approved,
		Subject:       idpResponse.Subject,
	}
	return &u, nil
}
327017
func (s profileService) AssignProfile(profileUUID string, devices []string) (*ProfileResponse, error) {
	var response ProfileResponse
	var request = struct {
		ProfileUUID string   `json:"profile_uuid"`
		Devices     []string `json:"devices"`
	}{profileUUID, devices}
	req, err := s.client.NewRequest("PUT", assignProfilePath, request)
	if err != nil {
		return nil, err
	}
	err = s.client.Do(req, &response)
	if err != nil {
		return nil, err
	}
	return &response, nil
}
682913
func (p *Profile) Copy() *Profile {
	pp := &Profile{}
	if err := unmarshal(serialize(p), pp); err != nil {
		panic(err)
	}
	if err := pp.postDecode(); err != nil {
		panic(err)
	}

	return pp
}