// AddResource adds in-memory resource to the compiler.
//
// Note that url must not have fragment
331976
func (c *Compiler) AddResource(url string, r io.Reader) error {
	res, err := newResource(url, r)
	if err != nil {
		return err
	}
	c.resources[res.url] = res
	return nil
}
749796
func (c *Client) GetResource(ctx context.Context, project *string, res *primitives.Resource) (*manifold.Resource, error) {
	rs, err := c.GetResources(ctx, project, []*primitives.Resource{res})
	if err != nil {
		return nil, err
	}

	if len(rs) > 1 {
		// Names are unique per project. If no project is specified it could be
		// that there are multiple resources.
		// TODO: figure out if we can setup a test for this.
		return nil, ErrMultipleResourcesFound
	}

	return rs[0], nil
}
1023815
func (t *Template) AddResource(resource NamedResource) {
	if _, ok := t.Resources[resource.Name]; ok {
		panic(fmt.Sprintf("%s is already defined in the template", resource.Name))
	}
	t.Resources[resource.Name] = resource.Resource
}
560468
func (m *Mux) AddSource(source io.Reader) {
	m.m.Lock()
	if m.closed {
		panic("mux: already closed")
	}
	if _, ok := m.readers[source]; ok {
		panic("mux: the io.Reader cannot be added multiple times")
	}
	m.readers[source] = bufio.NewReaderSize(source, 256)
	m.m.Unlock()
}
1232362
func (f *Facade) AddResourcePool(ctx datastore.Context, entity *pool.ResourcePool) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.AddResourcePool"))

	glog.Infof("Adding Resource Pool %s", entity.ID)

	alog := f.auditLogger.Message(ctx, "Adding Resource Pool").
		Action(audit.Add).Entity(entity)

	if err := f.DFSLock(ctx).LockWithTimeout("add resource pool", userLockTimeout); err != nil {
		glog.Warningf("Cannot add resource pool: %s", err)
		return alog.Error(err)
	}
	defer f.DFSLock(ctx).Unlock()

	return alog.Error(f.addResourcePool(ctx, entity))
}
448078
func (cache *charmstoreEntityCache) OpenResource(name string) (resource.Resource, io.ReadCloser, error) {
	if cache.unit == nil {
		return resource.Resource{}, nil, errors.NotImplementedf("")
	}
	return cache.st.OpenResourceForUniter(cache.unit, name)
}
591815
func (s *Staert) AddSource(src Source) {
	s.sources = append(s.sources, src)
}
901739
func (s *LambdaFunctionScheduledEventDetails) SetResource(v string) *LambdaFunctionScheduledEventDetails {
	s.Resource = &v
	return s
}
176947
func (cache *charmstoreEntityCache) SetResource(chRes charmresource.Resource, reader io.Reader) (resource.Resource, error) {
	return cache.st.SetResource(cache.applicationID, cache.userID.Id(), chRes, reader)
}
832586
func (r *RoleV2) SetResource(kind string, actions []string) {
	if r.Spec.Resources == nil {
		r.Spec.Resources = make(map[string][]string)
	}
	r.Spec.Resources[kind] = actions
}
180310
func UpdateResource(tx Tx, r *api.Resource) error {
	if err := confirmExtension(tx, r); err != nil {
		return err
	}
	return tx.update(tableResource, resourceEntry{r})
}
336166
func NewResource(value interface{}, config ...Config) *Resource {
	res := Resource{Resource: resource.New(value)}
	if len(config) > 0 {
		res.Config = &config[0]
	} else {
		res.Config = &Config{}
	}
	res.Permission = res.Config.Permission

	if res.Config.PrimaryField != "" {
		if err := res.SetPrimaryFields(res.Config.PrimaryField); err != nil {
			fmt.Println(err)
		}
	}
	return &res
}
319070
func (s *TaskStartedEventDetails) SetResource(v string) *TaskStartedEventDetails {
	s.Resource = &v
	return s
}
692597
func (resources *Resources) Add(that ...Resource) (rs Resources) {
	if resources != nil {
		rs = *resources
	}
	for i := range that {
		rs = rs._add(that[i])
	}
	if resources != nil {
		*resources = rs
	}
	return
}
732057
func NewResource(p interface{}, selfUri string) *Resource {
	var r Resource

	r.Payload = p

	r.Links = make(LinkRelations)
	r.AddNewLink("self", selfUri)

	r.Embedded = make(Embedded)
	r.Curies = make(map[string]*CurieHandle)

	return &r
}
55897
func (s *TaskSubmitFailedEventDetails) SetResource(v string) *TaskSubmitFailedEventDetails {
	s.Resource = &v
	return s
}
220635
func (p Protos) GetResource(resourceID string) (*resource.Resource, error) {
	url := p.createURL("resource/" + resourceID)
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return nil, err
	}

	res, err := p.makeRequest(req)
	if err != nil {
		return nil, err
	}

	rsc := resource.Resource{}
	err = json.Unmarshal(res, &rsc)
	if err != nil {
		return nil, err
	}
	return &rsc, nil
}