// AccountInfo parses the file at fileLoc into a GoogleCloudAccountFile and returns
// it. Returns nil and an appropriate error if any error occurred in reading or decoding.
175183
func AccountInfo(fileBase64 string) (*AccountFile, error) {
	decodedBytes, err := base64.StdEncoding.DecodeString(fileBase64)
	if err != nil {
		return nil, err
	}
	ret := new(AccountFile)
	if err := json.NewDecoder(bytes.NewBuffer(decodedBytes)).Decode(ret); err != nil {
		return nil, err
	}
	return ret, nil
}
287000
func (s *Service) KeyInfo(ctx context.Context, keyIdentity string) (*Key, error) {
	var key Key
	return &key, s.Get(ctx, &key, fmt.Sprintf("/account/keys/%v", keyIdentity), nil, nil)
}
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
}
1341683
func (xl xlObjects) StorageInfo(ctx context.Context) StorageInfo {
	return getStorageInfo(xl.getDisks())
}
1106416
func (c *Client) OAuthAuthorizationInfo(oauthAuthorizationIdentity string) (*OAuthAuthorization, error) {
	var oauthAuthorization OAuthAuthorization
	return &oauthAuthorization, c.Get(&oauthAuthorization, "/oauth/authorizations/"+oauthAuthorizationIdentity)
}
365473
func (st *State) fillInCloudUserAccess(user names.UserTag, cloudInfo []CloudInfo) error {
	// Note: Even for Superuser we track the individual Access for each model.
	username := strings.ToLower(user.Name())
	var permissionIds []string
	for _, info := range cloudInfo {
		permId := permissionID(cloudGlobalKey(info.Name), userGlobalKey(username))
		permissionIds = append(permissionIds, permId)
	}

	// Record index by name so we can fill access details below.
	indexByName := make(map[string]int, len(cloudInfo))
	for i, info := range cloudInfo {
		indexByName[info.Name] = i
	}

	perms, closer := st.db().GetCollection(permissionsC)
	defer closer()
	query := perms.Find(bson.M{"_id": bson.M{"$in": permissionIds}}).Batch(100)
	iter := query.Iter()

	var doc permissionDoc
	for iter.Next(&doc) {
		cloudName := strings.TrimPrefix(doc.ObjectGlobalKey, "cloud#")
		cloudIdx := indexByName[cloudName]

		details := &cloudInfo[cloudIdx]
		access := permission.Access(doc.Access)
		if err := access.Validate(); err == nil {
			details.Access = access
		}
	}
	return iter.Close()
}
987761
func (a *azureObjects) StorageInfo(ctx context.Context) (si minio.StorageInfo) {
	return si
}
4818
func (s *ObjectsClient) GetInfo(ctx context.Context, input *GetInfoInput) (*GetInfoOutput, error) {
	absPath := absFileInput(s.client.AccountName, input.ObjectPath)

	headers := &http.Header{}
	for key, value := range input.Headers {
		headers.Set(key, value)
	}

	reqInput := client.RequestInput{
		Method:  http.MethodHead,
		Path:    string(absPath),
		Headers: headers,
	}
	_, respHeaders, err := s.client.ExecuteRequestStorage(ctx, reqInput)
	if err != nil {
		return nil, errors.Wrap(err, "unable to get info")
	}

	response := &GetInfoOutput{
		ContentType: respHeaders.Get("Content-Type"),
		ContentMD5:  respHeaders.Get("Content-MD5"),
		ETag:        respHeaders.Get("Etag"),
	}

	lastModified, err := time.Parse(time.RFC1123, respHeaders.Get("Last-Modified"))
	if err == nil {
		response.LastModified = lastModified
	}

	contentLength, err := strconv.ParseUint(respHeaders.Get("Content-Length"), 10, 64)
	if err == nil {
		response.ContentLength = contentLength
	}

	metadata := map[string]string{}
	for key, values := range respHeaders {
		if strings.HasPrefix(key, "m-") {
			metadata[key] = strings.Join(values, ", ")
		}
	}
	response.Metadata = metadata

	return response, nil
}
98324
func (c *ApiController) GetAccountInfo() {
	fmt.Println("Start get account info")

	//user := GithubOauthUser{Name:"tobe", HTMLURL: "https://github.com/tobegit3hub", Company: "UnitedStack Inc"}

	client := github.NewClient(oauthCfg.Client(oauth2.NoContext, tkn))

	user, _, err := client.Users.Get("")
	if err != nil {
		fmt.Println("error getting name")
		//return
	}

	/*
		{
		"login": "tobegit3hub",
		"id": 2715000,
		"avatar_url": "https://avatars.githubusercontent.com/u/2715000?v=3",
		"html_url": "https://github.com/tobegit3hub",
		"gravatar_id": "",
		"name": "tobe",
		"company": "UnitedStack Inc",
		"blog": "http://chendihao.cn",
		"location": "Beijing",
		"email": "tobeg3oogle@gmail.com",
		"hireable": false,
		"public_repos": 161,
		"public_gists": 1,
		"followers": 155,
		"following": 68,
		"created_at": "2012-11-03T13:17:18Z",
		"updated_at": "2015-08-04T19:01:39Z",
		"type": "User",
		"site_admin": false,
		"url": "https://api.github.com/users/tobegit3hub",
		"events_url": "https://api.github.com/users/tobegit3hub/events{/privacy}",
		"following_url": "https://api.github.com/users/tobegit3hub/following{/other_user}",
		"followers_url": "https://api.github.com/users/tobegit3hub/followers",
		"gists_url": "https://api.github.com/users/tobegit3hub/gists{/gist_id}",
		"organizations_url": "https://api.github.com/users/tobegit3hub/orgs",
		"received_events_url": "https://api.github.com/users/tobegit3hub/received_events",
		"repos_url": "https://api.github.com/users/tobegit3hub/repos",
		"starred_url": "https://api.github.com/users/tobegit3hub/starred{/owner}{/repo}",
		"subscriptions_url": "https://api.github.com/users/tobegit3hub/subscriptions"
		}
	*/

	c.Data["json"] = user
	c.ServeJson()

}
1362449
func (ac *accountCache) scanAccounts() error {
	// Scan the entire folder metadata for file changes
	creates, deletes, updates, err := ac.fileC.scan(ac.keydir)
	if err != nil {
		log.Debug("Failed to reload keystore contents", "err", err)
		return err
	}
	if creates.Cardinality() == 0 && deletes.Cardinality() == 0 && updates.Cardinality() == 0 {
		return nil
	}
	// Create a helper method to scan the contents of the key files
	var (
		buf = new(bufio.Reader)
		key struct {
			Address string `json:"address"`
		}
	)
	readAccount := func(path string) *accounts.Account {
		fd, err := os.Open(path)
		if err != nil {
			log.Trace("Failed to open keystore file", "path", path, "err", err)
			return nil
		}
		defer fd.Close()
		buf.Reset(fd)
		// Parse the address.
		key.Address = ""
		err = json.NewDecoder(buf).Decode(&key)
		addr := common.HexToAddress(key.Address)
		switch {
		case err != nil:
			log.Debug("Failed to decode keystore key", "path", path, "err", err)
		case (addr == common.Address{}):
			log.Debug("Failed to decode keystore key", "path", path, "err", "missing or zero address")
		default:
			return &accounts.Account{
				Address: addr,
				URL:     accounts.URL{Scheme: KeyStoreScheme, Path: path},
			}
		}
		return nil
	}
	// Process all the file diffs
	start := time.Now()

	for _, p := range creates.ToSlice() {
		if a := readAccount(p.(string)); a != nil {
			ac.add(*a)
		}
	}
	for _, p := range deletes.ToSlice() {
		ac.deleteByFile(p.(string))
	}
	for _, p := range updates.ToSlice() {
		path := p.(string)
		ac.deleteByFile(path)
		if a := readAccount(path); a != nil {
			ac.add(*a)
		}
	}
	end := time.Now()

	select {
	case ac.notify <- struct{}{}:
	default:
	}
	log.Trace("Handled keystore changes", "time", end.Sub(start))
	return nil
}
565242
func (ud *UltraDns) GetAccountDetails() ([]AccInfo, error) {
	var Res struct {
		RInfo    ResultInfo `json:"resultInfo"`
		Accounts []AccInfo  `json:"accounts"`
	}

	_, body, err := ud.Client.Get(UltraHost+"/v1/accounts").
		Set("Authorization", ud.tokenHeader).End()
	if err != nil {
		return Res.Accounts, errors.New("Authentication Failed")
	}

	errr := json.Unmarshal([]byte(body), &Res)
	if errr != nil {
		return Res.Accounts, errors.New("Unmarshal Error")
	}

	return Res.Accounts, nil
}
741116
func isKnownStorageAccountType(t string) bool {
	for _, knownStorageAccountType := range knownStorageAccountTypes {
		if t == knownStorageAccountType {
			return true
		}
	}
	return false
}
1091914
func (s *Service) AppInfo(ctx context.Context, appIdentity string) (*App, error) {
	var app App
	return &app, s.Get(ctx, &app, fmt.Sprintf("/apps/%v", appIdentity), nil, nil)
}
243548
func (a *Client) Userinfo(params *UserinfoParams, authInfo runtime.ClientAuthInfoWriter) (*UserinfoOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewUserinfoParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "userinfo",
		Method:             "GET",
		PathPattern:        "/userinfo",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json", "application/x-www-form-urlencoded"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &UserinfoReader{formats: a.formats},
		AuthInfo:           authInfo,
		Context:            params.Context,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	return result.(*UserinfoOK), nil

}
432642
func (s *Service) AccountInfo(ctx context.Context) (*Account, error) {
	var account Account
	return &account, s.Get(ctx, &account, fmt.Sprintf("/account"), nil, nil)
}
94190
func (f *GFile) QueryInfo(attributes string, flags GFileQueryInfoFlags) (*GFileInfo, error) {
	ptr := C.CString(attributes)
	defer cfree(ptr)

	var gerror *C.GError

	gfileinfo := C.g_file_query_info(
		f.GFile,
		ptr,
		C.GFileQueryInfoFlags(flags),
		nil, // nil is GCancellable, not yet implemented
		&gerror,
	)
	if gerror != nil {
		return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
	}

	return &GFileInfo{gfileinfo}, nil
}
404553
func FileInfoFromCloudObject(path string, obj cloudstorage.Object) *FileInfo {

	fi := &FileInfo{Name: obj.Name(), obj: obj, Path: path}

	fi.Table = TableFromFileAndPath(path, obj.Name())

	// Get the part of path as follows
	//  /path/partialpath/filename.csv
	partialPath := strings.Replace(fi.Name, path, "", 1)
	parts := strings.Split(partialPath, "/")
	if len(parts) > 1 {
		fi.PartialPath = strings.Join(parts[0:len(parts)-1], "/")
	}
	//u.Debugf("Fi: name=%q table=%q  partial:%q partial2:%q", fi.Name, fi.Table, fi.PartialPath, partialPath)
	return fi
}