// ActiveUserProjects returns a full list of all config service projects with
// LogDog project configurations that the current user can see.
//
// The list will be alphabetically sorted.
424356
func ActiveUserProjects(c context.Context) ([]types.ProjectName, error) {
	return ProjectNames(c, cfgclient.AsUser)
}
561525
func ProjectFollowing() echo.HandlerFunc {

	// swagger:route GET /me/following/projects project info following GetMeProjectFollowing
	//
	// Shows the following informations for the specified user
	//
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile:read
	//
	//	Responses:
	//		default: MeFollowingProjects

	return func(c echo.Context) error {
		return user.ProjectFollowing()(c)
	}
}
659205
func (c *Client) ActivateProject(p *ActivateProjectParameter) (*Project, error) {
	obj, err := c.Request("activateProject", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Project), err
}
352102
func (o *Organization) ListProjects(ctx context.Context, opts ...PaginationOption) (ProjectList, Response, error) {
	path, err := paginate(fmt.Sprintf("/organizations/%s/projects", o.UUID), opts...)
	if err != nil {
		return ProjectList{}, Response{}, errors.Wrap(err, "unable to list projects")
	}

	body, resp, err := o.client.request(ctx, "GET", path, nil)
	if err != nil {
		return ProjectList{}, resp, errors.Wrap(err, "unable to list projects")
	}

	var projects ProjectList
	if err = json.Unmarshal(body, &projects); err != nil {
		return ProjectList{}, resp, errors.Wrap(err, "unable to unmarshal response into ProjectList")
	}

	return projects, resp, nil
}
380245
func GetAllProjects() []*Project {
	o := orm.NewOrm()

	var projects []*Project
	num, err := o.QueryTable("project").All(&projects)
	fmt.Printf("Returned Rows Num: %s, %s", num, err)
	return projects
}
981911
func validateProject(ctx *validation.Context, configSet, path string, content []byte) error {
	ctx.SetFile(path)
	cfg := v2.Config{}
	if err := proto.UnmarshalText(string(content), &cfg); err != nil {
		ctx.Error(err)
	} else {
		validateProjectConfig(ctx, &cfg)
	}
	return nil
}
643811
func GetAppProject(spec *argoappv1.ApplicationSpec, projLister applicationsv1.AppProjectLister, ns string) (*argoappv1.AppProject, error) {
	return projLister.AppProjects(ns).Get(spec.GetProject())
}
660961
func ProjectFollowing() echo.HandlerFunc {

	// swagger:route GET /users/{id}/following/projects project info following GetProjectFollowing
	//
	// Shows the following informations for the specified user
	//
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile:read
	//
	//	Responses:
	//		default: UsersIdFollowingProjects

	return func(c echo.Context) error {
		if !rest.IsGranted("profile:read", c) {
			return rest.InvalidScopeResponse("profile:read", c)
		}
		following := c.Get("other").(*nerdz.User).ProjectFollowing()
		return rest.SelectFields(rest.GetProjectsInfo(following), c)
	}
}
512164
func initializeDefaultProject(opts ArgoCDServerOpts) error {
	defaultProj := &v1alpha1.AppProject{
		ObjectMeta: metav1.ObjectMeta{Name: common.DefaultAppProjectName, Namespace: opts.Namespace},
		Spec: v1alpha1.AppProjectSpec{
			SourceRepos:              []string{"*"},
			Destinations:             []v1alpha1.ApplicationDestination{{Server: "*", Namespace: "*"}},
			ClusterResourceWhitelist: []metav1.GroupKind{{Group: "*", Kind: "*"}},
		},
	}

	_, err := opts.AppClientset.ArgoprojV1alpha1().AppProjects(opts.Namespace).Create(defaultProj)
	if apierrors.IsAlreadyExists(err) {
		return nil
	}
	return err
}
992077
func (c *ApiController) GetAccountProjects() {

	//projects := GithubOauthRepositories{{FullName:"ArchCI/archci", HTMLURL:"https://github.com/ArchCI/archci", Language: "Go", Description: "The best CI system"}, {FullName:"ArchCI/simple-worker", Homepage:"https://github.com/ArchCI/simple-worker", Language:"Go", Description: "The client of ArchCI"}}

	/*
		r := c.Ctx.Request
		w := c.Ctx.ResponseWriter

		token := tkn

		sess, _ := globalSessions.SessionStart(w, r)
		defer sess.SessionRelease(w)

		if sess.Get("token") == nil {
			token = sess.Get("token").(*oauth2.Token)

			fmt.Println("hit token")

		}
	*/

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

	projects, _, err := client.Repositories.List("", nil)
	if err != nil {
		fmt.Println("error getting repos")
		//return
	}

	/*
		[
		{
		"id": 36988569,
		"owner": {
		"login": "ArchCI",
		"id": 12673804,
		"avatar_url": "https://avatars.githubusercontent.com/u/12673804?v=3",
		"html_url": "https://github.com/ArchCI",
		"gravatar_id": "",
		"type": "Organization",
		"site_admin": false,
		"url": "https://api.github.com/users/ArchCI",
		"events_url": "https://api.github.com/users/ArchCI/events{/privacy}",
		"following_url": "https://api.github.com/users/ArchCI/following{/other_user}",
		"followers_url": "https://api.github.com/users/ArchCI/followers",
		"gists_url": "https://api.github.com/users/ArchCI/gists{/gist_id}",
		"organizations_url": "https://api.github.com/users/ArchCI/orgs",
		"received_events_url": "https://api.github.com/users/ArchCI/received_events",
		"repos_url": "https://api.github.com/users/ArchCI/repos",
		"starred_url": "https://api.github.com/users/ArchCI/starred{/owner}{/repo}",
		"subscriptions_url": "https://api.github.com/users/ArchCI/subscriptions"
		},
		"name": "aci",
		"full_name": "ArchCI/aci",
		"description": "Command-line client for ArchCI",
		"homepage": "http://archci.com",
		"default_branch": "master",
		"created_at": "2015-06-06T17:21:16Z",
		"pushed_at": "2015-06-14T01:00:11Z",
		"updated_at": "2015-06-28T13:58:55Z",
		"html_url": "https://github.com/ArchCI/aci",
		"clone_url": "https://github.com/ArchCI/aci.git",
		"git_url": "git://github.com/ArchCI/aci.git",
		"ssh_url": "git@github.com:ArchCI/aci.git",
		"svn_url": "https://github.com/ArchCI/aci",
		"language": "Go",
		"fork": false,
		"forks_count": 0,
		"open_issues_count": 0,
		"stargazers_count": 1,
		"watchers_count": 1,
		"size": 168,
		"permissions": {
		"admin": true,
		"pull": true,
		"push": true
		},
		"private": false,
		"has_issues": true,
		"has_wiki": true,
		"has_downloads": true,
		"team_id": null,
		"url": "https://api.github.com/repos/ArchCI/aci",
		"archive_url": "https://api.github.com/repos/ArchCI/aci/{archive_format}{/ref}",
		"assignees_url": "https://api.github.com/repos/ArchCI/aci/assignees{/user}",
		"blobs_url": "https://api.github.com/repos/ArchCI/aci/git/blobs{/sha}",
		"branches_url": "https://api.github.com/repos/ArchCI/aci/branches{/branch}",
		"collaborators_url": "https://api.github.com/repos/ArchCI/aci/collaborators{/collaborator}",
		"comments_url": "https://api.github.com/repos/ArchCI/aci/comments{/number}",
		"commits_url": "https://api.github.com/repos/ArchCI/aci/commits{/sha}",
		"compare_url": "https://api.github.com/repos/ArchCI/aci/compare/{base}...{head}",
		"contents_url": "https://api.github.com/repos/ArchCI/aci/contents/{+path}",
		"contributors_url": "https://api.github.com/repos/ArchCI/aci/contributors",
		"downloads_url": "https://api.github.com/repos/ArchCI/aci/downloads",
		"events_url": "https://api.github.com/repos/ArchCI/aci/events",
		"forks_url": "https://api.github.com/repos/ArchCI/aci/forks",
		"git_commits_url": "https://api.github.com/repos/ArchCI/aci/git/commits{/sha}",
		"git_refs_url": "https://api.github.com/repos/ArchCI/aci/git/refs{/sha}",
		"git_tags_url": "https://api.github.com/repos/ArchCI/aci/git/tags{/sha}",
		"hooks_url": "https://api.github.com/repos/ArchCI/aci/hooks",
		"issue_comment_url": "https://api.github.com/repos/ArchCI/aci/issues/comments{/number}",
		"issue_events_url": "https://api.github.com/repos/ArchCI/aci/issues/events{/number}",
		"issues_url": "https://api.github.com/repos/ArchCI/aci/issues{/number}",
		"keys_url": "https://api.github.com/repos/ArchCI/aci/keys{/key_id}",
		"labels_url": "https://api.github.com/repos/ArchCI/aci/labels{/name}",
		"languages_url": "https://api.github.com/repos/ArchCI/aci/languages",
		"merges_url": "https://api.github.com/repos/ArchCI/aci/merges",
		"milestones_url": "https://api.github.com/repos/ArchCI/aci/milestones{/number}",
		"notifications_url": "https://api.github.com/repos/ArchCI/aci/notifications{?since,all,participating}",
		"pulls_url": "https://api.github.com/repos/ArchCI/aci/pulls{/number}",
		"releases_url": "https://api.github.com/repos/ArchCI/aci/releases{/id}",
		"stargazers_url": "https://api.github.com/repos/ArchCI/aci/stargazers",
		"statuses_url": "https://api.github.com/repos/ArchCI/aci/statuses/{sha}",
		"subscribers_url": "https://api.github.com/repos/ArchCI/aci/subscribers",
		"subscription_url": "https://api.github.com/repos/ArchCI/aci/subscription",
		"tags_url": "https://api.github.com/repos/ArchCI/aci/tags",
		"trees_url": "https://api.github.com/repos/ArchCI/aci/git/trees{/sha}",
		"teams_url": "https://api.github.com/repos/ArchCI/aci/teams"
		}
		]
	*/

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

}
672413
func (api *TenantsAPI) GetProjects(tenantId string, options *ProjectGetOptions) (result *ProjectList, err error) {
	uri := api.client.Endpoint + tenantUrl + "/" + tenantId + "/projects"
	if options != nil {
		uri += getQueryString(options)
	}
	res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions)
	if err != nil {
		return
	}

	result = &(ProjectList{})
	err = json.Unmarshal(res, result)
	return
}
734129
func Convert_config_ProjectConfig_To_v1_ProjectConfig(in *config.ProjectConfig, out *v1.ProjectConfig, s conversion.Scope) error {
	return autoConvert_config_ProjectConfig_To_v1_ProjectConfig(in, out, s)
}
756749
func (c *Client) ListProjects(p *ListProjectsParameter) ([]*Project, error) {
	obj, err := c.Request("listProjects", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.([]*Project), err
}
1188779
func projectACLMiddleware(c *router.Context, next router.Handler) {
	luciProject := c.Params.ByName("project")
	switch allowed, err := common.IsAllowed(c.Context, luciProject); {
	case err != nil:
		ErrorHandler(c, err)
	case !allowed:
		if auth.CurrentIdentity(c.Context) == identity.AnonymousIdentity {
			ErrorHandler(c, errors.New("not logged in", grpcutil.UnauthenticatedTag))
		} else {
			ErrorHandler(c, errors.New("no access to project", grpcutil.PermissionDeniedTag))
		}
	default:
		c.Context = git.WithProject(c.Context, luciProject)
		next(c)
	}
}
1210806
func NewProject(context *ctx.Context, parseOptions *config.ParseOptions) (project.APIProject, error) {

	if err := context.LookupConfig(); err != nil {
		logrus.Errorf("Failed to load docker config: %v", err)
	}

	if context.AuthLookup == nil {
		context.AuthLookup = auth.NewConfigLookup(context.ConfigFile)
	}

	if context.ServiceFactory == nil {
		context.ServiceFactory = service.NewFactory(context)
	}

	if context.ClientFactory == nil {
		factory, err := client.NewDefaultFactory(client.Options{})
		if err != nil {
			return nil, err
		}
		context.ClientFactory = factory
	}

	if context.NetworksFactory == nil {
		networksFactory := &network.DockerFactory{
			ClientFactory: context.ClientFactory,
		}
		context.NetworksFactory = networksFactory
	}

	if context.VolumesFactory == nil {
		volumesFactory := &volume.DockerFactory{
			ClientFactory: context.ClientFactory,
		}
		context.VolumesFactory = volumesFactory
	}

	// FIXME(vdemeester) Remove the context duplication ?
	runtime := &Project{
		clientFactory: context.ClientFactory,
	}
	p := project.NewProject(&context.Context, runtime, parseOptions)

	err := p.Parse()
	if err != nil {
		return nil, err
	}

	return p, err
}
575855
func (r *ResourceDefinition) UserTypes() map[string]*UserTypeDefinition {
	types := make(map[string]*UserTypeDefinition)
	for _, a := range r.Actions {
		for n, ut := range a.UserTypes() {
			types[n] = ut
		}
	}
	if len(types) == 0 {
		return nil
	}
	return types
}
511901
func (user *User) ProjectHome(options PostlistOptions) *[]ProjectPost {
	var projectPost ProjectPost

	query := Db().Model(projectPost).Order("hpid DESC")
	query = projectPostlistConditions(query, user)

	options.Model = projectPost
	query = postlistQueryBuilder(query, options, user)

	var projectPosts []ProjectPost
	query.Scan(&projectPosts)

	return &projectPosts
}