// Content returns the "content" for the opened resource.
342310
func (o Opened) Content() Content {
	return Content{
		Data:        o.ReadCloser,
		Size:        o.Size,
		Fingerprint: o.Fingerprint,
	}
}
958583
func OpenResource(name string, client OpenedResourceClient) (*OpenedResource, error) {
	info, reader, err := client.GetResource(name)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if info.Type == charmresource.TypeContainerImage {
		info.Path = "content.yaml"
		// Image data is stored as json but we need to convert to YAMl
		// as that's what the charm expects.
		data, err := ioutil.ReadAll(reader)
		if err != nil {
			return nil, errors.Trace(err)
		}
		if err := reader.Close(); err != nil {
			return nil, errors.Trace(err)
		}
		var yamlBody resources.DockerImageDetails
		err = json.Unmarshal(data, &yamlBody)
		if err != nil {
			return nil, errors.Trace(err)
		}
		yamlOut, err := yaml.Marshal(yamlBody)
		if err != nil {
			return nil, errors.Trace(err)
		}
		reader = httprequest.BytesReaderCloser{bytes.NewReader(yamlOut)}
		info.Size = int64(len(yamlOut))
	}
	or := &OpenedResource{
		Resource:   info,
		ReadCloser: reader,
	}
	return or, nil
}
872159
func (t *Templater) Add(path, content string) (err error) {
	// Lock
	t.m.Lock()
	defer t.m.Unlock()

	// Parse content
	var tpl = template.New("root")
	if tpl, err = tpl.Parse(content); err != nil {
		err = errors.Wrapf(err, "astitemplate: parsing template content for path %s failed", path)
		return
	}

	// Parse files
	if tpl, err = tpl.ParseFiles(t.layouts...); err != nil {
		err = errors.Wrapf(err, "astitemplate: parsing layouts %s for path %s failed", strings.Join(t.layouts, ", "), path)
		return
	}

	// Add template
	t.templates[path] = tpl
	return
}
646128
func (d *domainClient) GetResourceContent(ctx context.Context, args *GetResourceContentArgs) (reply *GetResourceContentReply, err error) {
	reply = new(GetResourceContentReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "Page.getResourceContent", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "Page.getResourceContent", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "Page", Op: "GetResourceContent", Err: err}
	}
	return
}
256879
func (b *fixupBody) Content(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Diagnostics) {
	schema = b.effectiveSchema(schema)
	content, diags := b.original.Content(schema)
	return b.fixupContent(content), diags
}
1302876
func (h *Client) content(ctx context.Context, req *rls.GetReleaseContentRequest) (*rls.GetReleaseContentResponse, error) {
	c, err := h.connect(ctx)
	if err != nil {
		return nil, err
	}
	defer c.Close()

	rlc := rls.NewReleaseServiceClient(c)
	return rlc.GetReleaseContent(ctx, req)
}
753755
func (r *Request) Resource(s string) *Request {
	r.resource = s
	return r
}
1162420
func (b *itemBundle) Contents() (io.ReadCloser, error) {
	pr, pw := io.Pipe()
	go func() {
		pw.CloseWithError(b.writeTar(pw))
	}()
	return pr, nil
}
1364318
func (p *WebPage) Content() (string, error) {
	var resp struct {
		Value string `json:"value"`
	}
	if err := p.ref.process.doJSON("POST", "/webpage/Content", map[string]interface{}{"ref": p.ref.id}, &resp); err != nil {
		return "", err
	}
	return resp.Value, nil
}
335386
func (rw *responseStreamer) Resource() *Resource {
	r, err := rw.Stream.NextReader()
	if err == nil {
		b, err := ioutil.ReadAll(r)
		r.Close()
		if err == nil {
			return NewResourceBytes(rw.StatusCode, b, rw.Header())
		}
	}
	return &Resource{
		header:         rw.Header(),
		statusCode:     rw.StatusCode,
		ReadSeekCloser: errReadSeekCloser{err},
	}
}
469503
func (s *resourceServiceImpl) Read(ctx context.Context, resourceID string) (*app.Resource, error) {

	res, err := s.Repositories().ResourceRepository().Load(ctx, resourceID)
	if err != nil {
		return nil, err
	}

	// Load the resource type scopes
	scopes, err := s.Repositories().ResourceTypeScopeRepository().LookupForType(ctx, res.ResourceTypeID)
	if err != nil {
		return nil, errors.NewInternalError(ctx, err)
	}

	var scopeValues []string

	for index := range scopes {
		scopeValues = append(scopeValues, scopes[index].Name)
	}

	return &app.Resource{
		ResourceID:       &res.ResourceID,
		Type:             &res.ResourceType.Name,
		ParentResourceID: res.ParentResourceID,
		ResourceScopes:   scopeValues,
	}, nil
}
648924
func (t *tplate) loadContents() (err error) {
	if t.contents == "" {
		t.contents, err = readInput(t.name)
	}
	return err
}
775139
func (c *Config) LoadConfigFromContent(content []byte) (err error) {
	c.LoadDefaultConfig()

	err = yaml.Unmarshal(content, c)
	if err != nil {
		logger.Errorf(nil, "Config parse error, %v.", err)
		return
	}

	err = c.Check()
	if err != nil {
		return
	}

	logger.SetLevel(c.LogLevel)

	c.InitHTTPClient()
	return
}
1182556
func (c *xContext) NoContent(codes ...int) error {
	if len(codes) > 0 {
		c.code = codes[0]
	}
	if c.code == 0 {
		c.code = http.StatusOK
	}
	c.response.WriteHeader(c.code)
	return nil
}
442430
func (c *Page) GetResourceContent(frameId string, url string) (string, bool, error) {
	var v PageGetResourceContentParams
	v.FrameId = frameId
	v.Url = url
	return c.GetResourceContentWithParams(&v)
}
1358753
func PartialContent(w http.ResponseWriter, response interface{}) {
	Respond(w, http.StatusPartialContent, response)
}
742178
func (obj *Object) ContentWithContext(ctx context.Context) ([]byte, error) {
	if obj == nil {
		return nil, nil
	}
	if len(obj.Blob) > 0 || obj.Location == "" {
		return obj.Blob, nil
	}
	resp, err := ctxhttp.Get(ctx, nil, obj.Location)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return nil, errors.New(resp.Status)
	}
	ct := resp.Header.Get("Content-Type")
	if ct != "" {
		obj.ContentType = ct
	}
	blob, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	obj.Blob = blob
	return blob, nil
}