// Do not account for the system accounts.
965766
func (a *Account) numLocalConnections() int {
	return len(a.clients) - int(a.sysclients) - int(a.nleafs)
}
525193
func (s *AccountsService) CreateAccount(username string, input *AccountInput) (*AccountInfo, *Response, error) {
	u := fmt.Sprintf("accounts/%s", username)

	req, err := s.client.NewRequest("PUT", u, input)
	if err != nil {
		return nil, nil, err
	}

	v := new(AccountInfo)
	resp, err := s.client.Do(req, v)
	if err != nil {
		return nil, resp, err
	}

	return v, resp, err
}
1337406
func (s accountService) Account() (*Account, error) {
	var account Account
	req, err := s.client.NewRequest("GET", accountBasePath, nil)
	if err != nil {
		return nil, err
	}
	err = s.client.Do(req, &account)
	if err != nil {
		return nil, err
	}

	return &account, nil
}
508177
func (api *API) Accounts(pageOpts PaginationOptions) ([]Account, ResultInfo, error) {
	v := url.Values{}
	if pageOpts.PerPage > 0 {
		v.Set("per_page", strconv.Itoa(pageOpts.PerPage))
	}
	if pageOpts.Page > 0 {
		v.Set("page", strconv.Itoa(pageOpts.Page))
	}

	uri := "/accounts"
	if len(v) > 0 {
		uri = uri + "?" + v.Encode()
	}

	res, err := api.makeRequest("GET", uri, nil)
	if err != nil {
		return []Account{}, ResultInfo{}, errors.Wrap(err, errMakeRequestError)
	}

	var accListResponse AccountListResponse
	err = json.Unmarshal(res, &accListResponse)
	if err != nil {
		return []Account{}, ResultInfo{}, errors.Wrap(err, errUnmarshalError)
	}
	return accListResponse.Result, accListResponse.ResultInfo, nil
}
1275314
func (s *Server) fetchAccount(name string) (*Account, error) {
	if accClaims, claimJWT, err := s.fetchAccountClaims(name); accClaims != nil {
		// We have released the lock during the low level fetch.
		// Now that we are back under lock, check again if account
		// is in the map or not. If it is, simply return it.
		if v, ok := s.accounts.Load(name); ok {
			acc := v.(*Account)
			// Update with the new claims in case they are new.
			// Following call will return ErrAccountResolverSameClaims
			// if claims are the same.
			err = s.updateAccountWithClaimJWT(acc, claimJWT)
			if err != nil && err != ErrAccountResolverSameClaims {
				return nil, err
			}
			return acc, nil
		}
		acc := s.buildInternalAccount(accClaims)
		acc.claimJWT = claimJWT
		s.registerAccount(acc)
		return acc, nil
	} else {
		return nil, err
	}
}
986541
func (m *httpCreditManagerProxy) FetchCredits(uuid, serviceName string, operations []string) (*creditResponse, error) {
	params := url.Values{}
	params.Set("service", serviceName)
	params.Set("uuid", uuid)
	for _, op := range operations {
		params.Add("operations", op)
	}
	var resp creditResponse
	if err := utils.GetJSON(fmt.Sprintf("http://%s/credits?%s", m.hostPort, params.Encode()), &resp); err != nil {
		return nil, errors.Wrap(err, "Failed to receive credits from agent")
	}
	return &resp, nil
}
499020
func (s *Server) registerAccount(acc *Account) {
	if acc.sl == nil {
		acc.sl = NewSublist()
	}
	if acc.maxnae == 0 {
		acc.maxnae = DEFAULT_MAX_ACCOUNT_AE_RESPONSE_MAPS
	}
	if acc.maxaettl == 0 {
		acc.maxaettl = DEFAULT_TTL_AE_RESPONSE_MAP
	}
	if acc.clients == nil {
		acc.clients = make(map[*client]*client)
	}
	// If we are capable of routing we will track subscription
	// information for efficient interest propagation.
	// During config reload, it is possible that account was
	// already created (global account), so use locking and
	// make sure we create only if needed.
	acc.mu.Lock()
	// TODO(dlc)- Double check that we need this for GWs.
	if acc.rm == nil && s.opts != nil && s.shouldTrackSubscriptions() {
		acc.rm = make(map[string]int32)
	}
	acc.srv = s
	acc.mu.Unlock()
	s.accounts.Store(acc.Name, acc)
	s.enableAccountTracking(acc)
}
816648
func (az *Cloud) getStorageAccounts(matchingAccountType, matchingAccountKind, resourceGroup, matchingLocation string) ([]accountWithLocation, error) {
	ctx, cancel := getContextWithCancel()
	defer cancel()
	result, err := az.StorageAccountClient.ListByResourceGroup(ctx, resourceGroup)
	if err != nil {
		return nil, err
	}
	if result.Value == nil {
		return nil, fmt.Errorf("unexpected error when listing storage accounts from resource group %s", resourceGroup)
	}

	accounts := []accountWithLocation{}
	for _, acct := range *result.Value {
		if acct.Name != nil && acct.Location != nil && acct.Sku != nil {
			storageType := string((*acct.Sku).Name)
			if matchingAccountType != "" && !strings.EqualFold(matchingAccountType, storageType) {
				continue
			}

			if matchingAccountKind != "" && !strings.EqualFold(matchingAccountKind, string(acct.Kind)) {
				continue
			}

			location := *acct.Location
			if matchingLocation != "" && !strings.EqualFold(matchingLocation, location) {
				continue
			}
			accounts = append(accounts, accountWithLocation{Name: *acct.Name, StorageType: storageType, Location: location})
		}
	}

	return accounts, nil
}
700248
func unlockAccount(ks *keystore.KeyStore, address string, i int, passwords []string) (accounts.Account, string) {
	account, err := utils.MakeAddress(ks, address)
	if err != nil {
		utils.Fatalf("Could not list accounts: %v", err)
	}
	for trials := 0; trials < 3; trials++ {
		prompt := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", address, trials+1, 3)
		password := getPassPhrase(prompt, false, i, passwords)
		err = ks.Unlock(account, password)
		if err == nil {
			log.Info("Unlocked account", "address", account.Address.Hex())
			return account, password
		}
		if err, ok := err.(*keystore.AmbiguousAddrError); ok {
			log.Info("Unlocked account", "address", account.Address.Hex())
			return ambiguousAddrRecovery(ks, err, password), password
		}
		if err != keystore.ErrDecrypt {
			// No need to prompt again if the error is not decryption-related.
			break
		}
	}
	// All trials expended to unlock account, bail out
	utils.Fatalf("Failed to unlock account %s (%v)", address, err)

	return accounts.Account{}, ""
}
889775
func Reject(id string, params *stripe.AccountRejectParams) (*stripe.Account, error) {
	return getC().Reject(id, params)
}
959647
func (ks *KeyStore) DeleteAccount(account *Account, passphrase string) error {
	return ks.keystore.Delete(account.account, passphrase)
}
108989
func (a AzureCLI) ListAccounts() ([]Account, error) {
	var accounts []Account
	if err := a.run(&accounts, "account", "list"); err != nil {
		return nil, errors.Trace(err)
	}
	return accounts, nil
}
760110
func (w *Wallet) Accounts() []accounts.Account {
	// Attempt self-derivation if it's running
	reqc := make(chan struct{}, 1)
	select {
	case w.deriveReq <- reqc:
		// Self-derivation request accepted, wait for it
		<-reqc
	default:
		// Self-derivation offline, throttled or busy, skip
	}

	w.lock.Lock()
	defer w.lock.Unlock()

	if pairing := w.Hub.pairing(w); pairing != nil {
		ret := make([]accounts.Account, 0, len(pairing.Accounts))
		for address, path := range pairing.Accounts {
			ret = append(ret, w.makeAccount(address, path))
		}
		sort.Sort(accounts.AccountsByURL(ret))
		return ret
	}
	return nil
}
935913
func (v *version) ServiceAccounts() ServiceAccountInformer {
	return &serviceAccountInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
177350
func (r FlexibleCredit_Program) SelfEnrollNewAccount(accountTemplate *datatypes.Account) (resp datatypes.Account, err error) {
	params := []interface{}{
		accountTemplate,
	}
	err = r.Session.DoRequest("SoftLayer_FlexibleCredit_Program", "selfEnrollNewAccount", params, &r.Options, &resp)
	return
}
574452
func (c *MemStore) AccountDetails(controllerName string) (*AccountDetails, error) {
	c.mu.Lock()
	defer c.mu.Unlock()

	if err := ValidateControllerName(controllerName); err != nil {
		return nil, err
	}
	details, ok := c.Accounts[controllerName]
	if !ok {
		return nil, errors.NotFoundf("account for controller %s", controllerName)
	}
	return &details, nil
}
879103
func (c *ownAccountLookupCacheImpl) OwnAccount(ctx context.Context, accountID stellar1.AccountID) (own bool, accountName string, err error) {
	c.RLock()
	defer c.RLock()
	if c.loadErr != nil {
		return false, "", c.loadErr
	}
	name := c.accounts[accountID]
	if name == nil {
		return false, "", nil
	}
	return true, *name, nil
}