// Monitorscopes retrieves the list of child Monitorscopes of the Application
515029
func (o *Application) Monitorscopes(info *bambou.FetchingInfo) (MonitorscopesList, *bambou.Error) {

	var list MonitorscopesList
	err := bambou.CurrentSession().FetchChildren(o, MonitorscopeIdentity, &list, info)
	return list, err
}
1204586
func (u *Unit) RelationsInScope() ([]*Relation, error) {
	return u.relations(func(ru *RelationUnit) (bool, error) {
		return ru.InScope()
	})
}
819484
func (o *Application) CreateMonitorscope(child *Monitorscope) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
257595
func (b *BigIP) Monitors() ([]Monitor, error) {
	var monitors []Monitor
	monitorUris := []string{
		"gateway-icmp",
		"http",
		"https",
		"icmp",
		"inband",
		"mysql",
		"postgresql",
		"tcp",
		"udp",
	}

	for _, name := range monitorUris {
		var m Monitors
		err, _ := b.getForEntity(&m, uriLtm, uriMonitor, name)
		if err != nil {
			return nil, err
		}
		for _, monitor := range m.Monitors {
			monitor.MonitorType = name
			monitors = append(monitors, monitor)
		}
	}

	return monitors, nil
}
593480
func (s *StorageProvisionerAPIv3) WatchFilesystems(args params.Entities) (params.StringsWatchResults, error) {
	w := filesystemwatcher.Watchers{s.sb}
	return s.watchStorageEntities(args,
		w.WatchModelManagedFilesystems,
		w.WatchMachineManagedFilesystems,
		w.WatchUnitManagedFilesystems)
}
338408
func (claims *Claims) HasScope(scope string) bool {
	return claims != nil && contains(claims.Scope, scope)
}
666918
func (c *Client) GetAllProvisionWatchers() ([]contract.ProvisionWatcher, error) {
	conn := c.Pool.Get()
	defer conn.Close()

	objects, err := getObjectsByRange(conn, db.ProvisionWatcher, 0, -1)
	if err != nil {
		return []contract.ProvisionWatcher{}, err
	}

	pw := make([]contract.ProvisionWatcher, len(objects))
	for i, object := range objects {
		err = unmarshalProvisionWatcher(object, &pw[i])
		if err != nil {
			return []contract.ProvisionWatcher{}, err
		}
	}

	return pw, nil
}
1329879
func getSecurityScopes(ss raml.DefinitionChoice) ([]string, error) {
	scopes := []string{}

	// check if there is scopes
	v, ok := ss.Parameters["scopes"]
	if !ok {
		return scopes, nil
	}

	// cast it to []string, return error if failed
	scopesArr, ok := v.([]interface{})
	if !ok {
		return scopes, fmt.Errorf("scopes must be array")
	}

	// build []string
	for _, s := range scopesArr {
		scopes = append(scopes, s.(string))
	}
	return scopes, nil
}
900666
func (c *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) {
	panic("not implemented")
}
1307026
func (om *Oauth2oauth_2_0Middleware) CheckScopes(scopes []string) bool {
	if len(om.Scopes) == 0 {
		return true
	}

	for _, allowed := range om.Scopes {
		for _, scope := range scopes {
			if scope == allowed {
				return true
			}
		}
	}
	return false
}
1275909
func (a *Application) WatchUnits() StringsWatcher {
	members := bson.D{{"application", a.doc.Name}}
	prefix := a.doc.Name + "/"
	filter := func(unitDocID interface{}) bool {
		unitName, err := a.st.strictLocalID(unitDocID.(string))
		if err != nil {
			return false
		}
		return strings.HasPrefix(unitName, prefix)
	}
	return newLifecycleWatcher(a.st, unitsC, members, filter, nil)
}
767535
func (o *VSC) MonitoringPorts(info *bambou.FetchingInfo) (MonitoringPortsList, *bambou.Error) {

	var list MonitoringPortsList
	err := bambou.CurrentSession().FetchChildren(o, MonitoringPortIdentity, &list, info)
	return list, err
}
717877
func (w *relationUnitsWatcher) mergeScope(changes *params.RelationUnitsChange, c *RelationScopeChange) error {
	docIds := make([]interface{}, len(c.Entered))
	for i, name := range c.Entered {
		key := w.sw.prefix + name
		docID := w.backend.docID(key)
		docIds[i] = docID
	}
	logger.Tracef("relationUnitsWatcher %q watching newly entered: %v, and unwatching left %v", w.sw.prefix, c.Entered, c.Left)
	if err := w.watcher.WatchMulti(settingsC, docIds, w.updates); err != nil {
		return errors.Trace(err)
	}
	for _, docID := range docIds {
		w.watching.Add(docID.(string))
	}
	for _, name := range c.Entered {
		key := w.sw.prefix + name
		if err := w.mergeSettings(changes, key); err != nil {
			return errors.Annotatef(err, "while merging settings for %q entering relation scope", name)
		}
		changes.Departed = remove(changes.Departed, name)
	}
	for _, name := range c.Left {
		key := w.sw.prefix + name
		docID := w.backend.docID(key)
		changes.Departed = append(changes.Departed, name)
		if changes.Changed != nil {
			delete(changes.Changed, name)
		}
		w.watcher.Unwatch(settingsC, docID, w.updates)
		w.watching.Remove(docID)
	}
	logger.Tracef("relationUnitsWatcher %q Change updated to: %# v", w.sw.prefix, changes)
	return nil
}
36833
func (u *Unit) WatchApplicationConfigSettings() (NotifyWatcher, error) {
	applicationConfigKey := applicationConfigKey(u.ApplicationName())
	return newEntityWatcher(u.st, settingsC, u.st.docID(applicationConfigKey)), nil
}
339584
func (m *Machine) WatchContainers() (watcher.StringsWatcher, error) {
	var result params.StringsWatchResult
	arg := params.Entity{Tag: m.tag.String()}
	err := m.facade.FacadeCall("WatchContainers", arg, &result)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if result.Error != nil {
		return nil, result.Error
	}
	return apiwatcher.NewStringsWatcher(m.facade.RawAPICaller(), result), nil
}
1135835
func (s *Method) SetAuthorizationScopes(v []*string) *Method {
	s.AuthorizationScopes = v
	return s
}
163409
func (v *Vars) OpenScope(th *starlark.Thread) {
	v.scopes = append(v.scopes, &scope{thread: th})
}