// GET /monitoring_policies/{id}/servers
485442
func (api *API) ListMonitoringPolicyServers(mp_id string) ([]Identity, error) {
	result := []Identity{}
	url := createUrl(api, monitorPolicyPathSegment, mp_id, "servers")
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}
	return result, nil
}
210867
func GetPolicies(statements []Statement, bucketName, prefix string) map[string]BucketPolicy {
	policyRules := map[string]BucketPolicy{}
	objResources := set.NewStringSet()
	// Search all resources related to objects policy
	for _, s := range statements {
		for r := range s.Resources {
			if strings.HasPrefix(r, awsResourcePrefix+bucketName+"/"+prefix) {
				objResources.Add(r)
			}
		}
	}

	// Pretend that policy resource as an actual object and fetch its policy
	for r := range objResources {
		// Put trailing * if exists in asterisk
		asterisk := ""
		if strings.HasSuffix(r, "*") {
			r = r[:len(r)-1]
			asterisk = "*"
		}
		var objectPath string
		if len(r) >= len(awsResourcePrefix+bucketName)+1 {
			objectPath = r[len(awsResourcePrefix+bucketName)+1:]
		}
		p := GetPolicy(statements, bucketName, objectPath)
		policyRules[bucketName+"/"+objectPath+asterisk] = p
	}
	return policyRules
}
430930
func (a *ACL) GetPolicies(args *structs.ACLPolicySetRequest, reply *structs.ACLPolicySetResponse) error {
	if !a.srv.config.ACLEnabled {
		return aclDisabled
	}
	if done, err := a.srv.forward("ACL.GetPolicies", args, args, reply); done {
		return err
	}
	defer metrics.MeasureSince([]string{"nomad", "acl", "get_policies"}, time.Now())

	var token *structs.ACLToken
	var err error
	if args.AuthToken == "" {
		// No need to look up the anonymous token
		token = structs.AnonymousACLToken
	} else {
		// For client typed tokens, allow them to query any policies associated with that token.
		// This is used by clients which are resolving the policies to enforce. Any associated
		// policies need to be fetched so that the client can determine what to allow.
		token, err = a.srv.State().ACLTokenBySecretID(nil, args.AuthToken)
		if err != nil {
			return err
		}
	}

	if token == nil {
		return structs.ErrTokenNotFound
	}
	if token.Type != structs.ACLManagementToken && !token.PolicySubset(args.Names) {
		return structs.ErrPermissionDenied
	}

	// Setup the blocking query
	opts := blockingOptions{
		queryOpts: &args.QueryOptions,
		queryMeta: &reply.QueryMeta,
		run: func(ws memdb.WatchSet, state *state.StateStore) error {
			// Setup the output
			reply.Policies = make(map[string]*structs.ACLPolicy, len(args.Names))

			// Look for the policy
			for _, policyName := range args.Names {
				out, err := state.ACLPolicyByName(ws, policyName)
				if err != nil {
					return err
				}
				if out != nil {
					reply.Policies[policyName] = out
				}
			}

			// Use the last index that affected the policy table
			index, err := state.Index("acl_policy")
			if err != nil {
				return err
			}
			reply.Index = index
			return nil
		}}
	return a.srv.blockingRPC(&opts)
}
232977
func (o *Enterprise) RoutingPolicies(info *bambou.FetchingInfo) (RoutingPoliciesList, *bambou.Error) {

	var list RoutingPoliciesList
	err := bambou.CurrentSession().FetchChildren(o, RoutingPolicyIdentity, &list, info)
	return list, err
}
531262
func (r Account) GetThirdPartyPoliciesAcceptanceStatus() (resp []datatypes.Container_Policy_Acceptance, err error) {
	err = r.Session.DoRequest("SoftLayer_Account", "getThirdPartyPoliciesAcceptanceStatus", nil, &r.Options, &resp)
	return
}
880633
func (p *Predict) policies() []string {
	client := p.Client()
	if client == nil {
		return nil
	}

	policies, err := client.Sys().ListPolicies()
	if err != nil {
		return nil
	}
	sort.Strings(policies)
	return policies
}
1257576
func (c *AgentCheckCommand) checkServerHealth(info map[string]map[string]string, minPeers int) int {
	raft := info["raft"]
	knownPeers, err := strconv.Atoi(raft["num_peers"])
	if err != nil {
		c.Ui.Output(fmt.Sprintf("unable to get known peers: %v", err))
		return HealthCritical
	}

	if knownPeers < minPeers {
		c.Ui.Output(fmt.Sprintf("known peers: %v, is less than expected number of peers: %v", knownPeers, minPeers))
		return HealthCritical
	}
	return HealthPass
}
1221623
func GetServiceStateIDs(conn client.Connection, poolID, serviceID string) ([]StateRequest, error) {
	logger := plog.WithField("serviceid", serviceID)

	basepth := "/"
	if poolID != "" {
		basepth = path.Join("/pools", poolID)
	}

	spth := path.Join(basepth, "/services", serviceID)
	ch, err := conn.Children(spth)
	if err != nil && err != client.ErrNoNode {

		logger.WithError(err).Debug("Could not look up states on service")

		// TODO: wrap the error?
		return nil, err
	}

	states := make([]StateRequest, len(ch))
	for i, stateID := range ch {
		hostID, _, instanceID, err := ParseStateID(stateID)
		if err != nil {
			logger.WithField("stateid", stateID).WithError(err).Debug("Could not parse state")
			return nil, err
		}

		states[i] = StateRequest{
			PoolID:     poolID,
			HostID:     hostID,
			ServiceID:  serviceID,
			InstanceID: instanceID,
		}
	}

	logger.WithField("statecount", len(states)).Debug("Loaded state ids")
	return states, nil
}
961522
func (s *SchedulePolicyServer) Inspect(
	ctx context.Context,
	req *api.SdkSchedulePolicyInspectRequest,
) (*api.SdkSchedulePolicyInspectResponse, error) {
	if s.cluster() == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	if len(req.GetName()) == 0 {
		return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name")
	}

	policy, err := s.cluster().SchedPolicyGet(req.GetName())
	if err != nil {
		if err == kvdb.ErrNotFound {
			return nil, status.Errorf(
				codes.NotFound,
				"Schedule policy %s not found",
				req.GetName())
		}
		return nil, status.Errorf(
			codes.Internal,
			"Failed to inspect schedule policy: %v",
			err.Error())
	}

	schedules, err := retainInternalSpecYamlByteToSdkSched([]byte(policy.Schedule))
	if err != nil {
		return nil, err
	}

	sdkpolicy := &api.SdkSchedulePolicy{
		Name:      policy.Name,
		Schedules: schedules,
	}

	return &api.SdkSchedulePolicyInspectResponse{Policy: sdkpolicy}, err
}
396445
func (s *ConfigService) GetServerInfo() (*ServerInfo, *Response, error) {
	u := "config/server/info"

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

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

	return v, resp, err
}
1252785
func GetServerByID(id string) (*cluster.Server, error) {
	return app.serviceDiscovery.GetServer(id)
}
615555
func (s *Server) getHealthchecks() (*Checks, error) {
	engineConn, err := net.DialTimeout("unix", s.config.EngineSocket, engineTimeout)
	if err != nil {
		return nil, fmt.Errorf("Dial failed: %v", err)
	}
	engineConn.SetDeadline(time.Now().Add(engineTimeout))
	engine := rpc.NewClient(engineConn)
	defer engine.Close()

	var checks Checks
	ctx := ipc.NewTrustedContext(seesaw.SCHealthcheck)
	if err := engine.Call("SeesawEngine.Healthchecks", ctx, &checks); err != nil {
		return nil, fmt.Errorf("SeesawEngine.Healthchecks failed: %v", err)
	}

	return &checks, nil
}
1241196
func (api *API) GetServerAppliance(sa_id string) (*ServerAppliance, error) {
	res := new(ServerAppliance)
	url := createUrl(api, serverAppliancePathSegment, sa_id)
	err := api.Client.Get(url, &res, http.StatusOK)
	if err != nil {
		return nil, err
	}
	//	res.api = api
	return res, nil
}
393987
func (s *PresenceService) GetAuthServers() ([]services.Server, error) {
	return s.getServers(services.KindAuthServer, authServersPrefix)
}
544697
func (c *Connection) GetDataRetrievalPolicy() (DataRetrievalPolicy, int, error) {
	// Build request.
	request, err := http.NewRequest("GET", c.policy("data-retrieval"), nil)
	if err != nil {
		return 0, 0, err
	}
	request.Header.Add("x-amz-glacier-version", "2012-06-01")

	c.Signature.Sign(request, nil)

	// Perform request.
	response, err := c.client().Do(request)
	if err != nil {
		return 0, 0, err
	}
	defer response.Body.Close()

	if response.StatusCode != http.StatusOK {
		return 0, 0, aws.ParseError(response)
	}

	// Parse success response.
	var policy dataRetrievalPolicy
	decoder := json.NewDecoder(response.Body)
	err = decoder.Decode(&policy)
	if err != nil {
		return 0, 0, err
	}

	var bytesPerHour int
	if policy.Policy.Rules[0].BytesPerHour != nil {
		bytesPerHour = *policy.Policy.Rules[0].BytesPerHour
	}
	strategy := ToDataRetrievalPolicy(policy.Policy.Rules[0].Strategy)

	return strategy, bytesPerHour, nil
}
1366505
func (c *Client) GetAuthServers() ([]services.Server, error) {
	out, err := c.Get(c.Endpoint("authservers"), url.Values{})
	if err != nil {
		return nil, trace.Wrap(err)
	}
	var items []json.RawMessage
	if err := json.Unmarshal(out.Bytes(), &items); err != nil {
		return nil, trace.Wrap(err)
	}
	re := make([]services.Server, len(items))
	for i, raw := range items {
		server, err := services.GetServerMarshaler().UnmarshalServer(raw, services.KindAuthServer, services.SkipValidation())
		if err != nil {
			return nil, trace.Wrap(err)
		}
		re[i] = server
	}
	return re, nil
}
20671
func (s *IssueService) GetWatchers(issueID string) (*[]User, *Response, error) {
	watchesAPIEndpoint := fmt.Sprintf("rest/api/2/issue/%s/watchers", issueID)

	req, err := s.client.NewRequest("GET", watchesAPIEndpoint, nil)
	if err != nil {
		return nil, nil, err
	}

	watches := new(Watches)
	resp, err := s.client.Do(req, watches)
	if err != nil {
		return nil, nil, NewJiraError(resp, err)
	}

	result := []User{}
	user := new(User)
	for _, watcher := range watches.Watchers {
		user, resp, err = s.client.User.Get(watcher.Name)
		if err != nil {
			return nil, resp, NewJiraError(resp, err)
		}
		result = append(result, *user)
	}

	return &result, resp, nil
}