// NewGrantCheck returns a new GrantCheck
429550
func NewGrantCheck(check GrantChecker, handler GrantHandler, errorHandler GrantErrorHandler) osinserver.AuthorizeHandler {
	return &GrantCheck{check, handler, errorHandler}
}
316475
func (s *CreateBucketInput) SetGrantFullControl(v string) *CreateBucketInput {
	s.GrantFullControl = &v
	return s
}
857629
func (d *Driver) PreCreateCheck() error {

	if err := d.checkKeyPair(); err != nil {
		return err
	}

	if err := d.checkInstance(); err != nil {
		return err
	}

	return nil
}
586067
func (api OrganizationsAPI) CreateUserGrant(w http.ResponseWriter, r *http.Request) {
	globalid := mux.Vars(r)["globalid"]

	body := struct {
		Username string       `json:"username"`
		Grant    grants.Grant `json:"grant"`
	}{}
	if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
		log.Debug("Error decoding create grant body:", err)
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	if err := body.Grant.Validate(); err != nil {
		log.Debug("Invalid grant: ", err)
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	userObj, err := SearchUser(r, body.Username)
	if err != nil && !db.IsNotFound(err) {
		log.Error("Failed to look up user identifier: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	if err != nil {
		// We can't give a grant to a user that doesn't exist
		http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
		return
	}

	hasAuth, err := hasAuthorization(r, userObj.Username, globalid)
	if handleServerError(w, "checking if user has an authorization for the organization", err) {
		return
	}
	if !hasAuth {
		log.Debug("Refusing to give a grant to a user without authorization")
		w.WriteHeader(http.StatusForbidden)
		w.Write([]byte("User does not have an authorization for this organzation"))
		return
	}

	grantMgr := grants.NewManager(r)
	err = grantMgr.UpserGrant(userObj.Username, globalid, body.Grant)
	if err != nil && err != grants.ErrGrantLimitReached {
		log.Error("Failed to create user grant: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	if err != nil {
		log.Debug("Max amount of grants reached")
		http.Error(w, http.StatusText(http.StatusConflict), http.StatusConflict)
	}

	grantObj, err := grantMgr.GetGrantsForUser(userObj.Username, globalid)
	if err != nil {
		log.Error("Failed to look up user grants: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusCreated)
	json.NewEncoder(w).Encode(grantObj.Grants)
}
288453
func (v *vserver) expandChecks() map[checkKey]*check {
	checks := make(map[checkKey]*check)
	for _, svc := range v.services {
		for _, dest := range svc.dests {
			dest.checks = make([]*check, 0)
			if !dest.backend.Enabled {
				continue
			}
			for _, hc := range v.config.Healthchecks {
				// vserver-level healthchecks
				key := newCheckKey(svc.ip, dest.ip, 0, 0, hc)
				c := checks[key]
				if c == nil {
					c = newCheck(key, v, hc)
					checks[key] = c
				}
				dest.checks = append(dest.checks, c)
				c.dests = append(c.dests, dest)
			}

			// ventry-level healthchecks
			if v.config.UseFWM {
				for _, ve := range svc.vserver.config.Entries {
					for _, hc := range ve.Healthchecks {
						key := newCheckKey(svc.ip, dest.ip, ve.Port, ve.Proto, hc)
						c := newCheck(key, v, hc)
						checks[key] = c
						dest.checks = append(dest.checks, c)
						c.dests = append(c.dests, dest)
					}
				}
			} else {
				for _, hc := range svc.ventry.Healthchecks {
					key := newCheckKey(svc.ip, dest.ip, svc.port, svc.proto, hc)
					c := newCheck(key, v, hc)
					checks[key] = c
					dest.checks = append(dest.checks, c)
					c.dests = append(c.dests, dest)
				}
			}
		}
	}
	return checks
}
589536
func NewHealthcheck(m seesaw.HealthcheckMode, t seesaw.HealthcheckType, port uint16) *Healthcheck {
	return &Healthcheck{
		Mode: m,
		Type: t,
		Port: port,
	}
}
269124
func NewBatchChecker(backend ExecutorState, params Params, blockchain contexts.Blockchain, logger *logging.Logger,
	options ...ExecutionOption) BatchExecutor {

	return newExecutor("CheckCache", false, params, backend, blockchain, nil,
		logger.WithScope("NewBatchExecutor"), options...)
}
1078694
func NewCheckpointManager(checkpointDir string) (CheckpointManager, error) {
	fstore, err := utilstore.NewFileStore(checkpointDir, utilfs.DefaultFs{})
	if err != nil {
		return nil, err
	}

	return &impl{path: checkpointDir, store: fstore}, nil
}
735667
func (s *EncryptInput) SetGrantTokens(v []*string) *EncryptInput {
	s.GrantTokens = v
	return s
}
434163
func NewHealthCheck() http.Handler {
	return api.HTTPHandler{
		Handler: api.HandlerFunc(healthHandler),
		Methods: []string{"GET"},
	}
}
203974
func (c *Check) AddReadyCheck(check Checker) {
	if nc, ok := check.(NamedChecker); ok {
		c.readyChecks = append(c.readyChecks, Named(nc.CheckName(), nc))
	} else {
		c.readyChecks = append(c.readyChecks, check)
	}
}
284011
func NewHealthChecks(basePath string, next http.Handler) *HealthChecks {
	if basePath == "" {
		basePath = "/"
	}

	return &HealthChecks{basePath: basePath, next: next}
}
1363320
func (s *S3Grant) SetGrantee(v *S3Grantee) *S3Grant {
	s.Grantee = v
	return s
}
727808
func NewCheckCommand(stdin io.Reader, stdout, stderr io.Writer) *CheckCommand {
	return &CheckCommand{
		CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr),
	}
}
1315065
func NewBackend(delegate audit.Backend, p policy.Checker) audit.Backend {
	return &Backend{
		policyChecker:   p,
		delegateBackend: delegate,
	}
}
484535
func NewCheckSup(s string) (checkSup, error) {
	var e checkSup
	err := e.FromString(s)
	if err != nil {
		return 0, err
	}
	return e, nil
}
1160008
func (a *Agent) RemoveCheck(checkID types.CheckID, persist bool) error {
	a.stateLock.Lock()
	defer a.stateLock.Unlock()
	return a.removeCheckLocked(checkID, persist)
}