• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang openstack.Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中git/openstack/org/stackforge/golang-client/git/openstack.Session的典型用法代码示例。如果您正苦于以下问题:Golang Session类的具体用法?Golang Session怎么用?Golang Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Session类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetObjectMeta

//GetObjectMeta calls the OpenStack retrieve object metadata API using
//previously obtained token.
func GetObjectMeta(session *openstack.Session, url string) (http.Header, error) {
	resp, err := session.Head(url, nil, nil)
	if err != nil {
		return nil, err
	}
	return resp.Header, util.CheckHTTPResponseStatusCode(resp)
}
开发者ID:hbellur,项目名称:golang-client,代码行数:9,代码来源:objectstorage.go


示例2: ListObjects

//ListObjects calls the OpenStack list object API using previously
//obtained token. "Limit", "marker", "prefix", "path", "delim" corresponds
//to the API's "limit", "marker", "prefix", "path", and "delimiter".
func ListObjects(session *openstack.Session, limit int64,
	marker, prefix, path, delim, conURL string) ([]byte, error) {
	var query url.Values = url.Values{}
	query.Add("format", "json")
	if limit > 0 {
		query.Add("limit", strconv.FormatInt(limit, 10))
	}
	if marker != "" {
		query.Add("marker", url.QueryEscape(marker))
	}
	if prefix != "" {
		query.Add("prefix", url.QueryEscape(prefix))
	}
	if path != "" {
		query.Add("path", url.QueryEscape(path))
	}
	if delim != "" {
		query.Add("delimiter", url.QueryEscape(delim))
	}
	resp, err := session.Get(conURL, &query, nil)
	if err != nil {
		return nil, err
	}
	if err = util.CheckHTTPResponseStatusCode(resp); err != nil {
		return nil, err
	}
	body, err := ioutil.ReadAll(resp.Body)
	defer resp.Body.Close()
	if err != nil {
		return []byte{}, err
	}
	return body, nil
}
开发者ID:hbellur,项目名称:golang-client,代码行数:36,代码来源:objectstorage.go


示例3: DeleteObject

//DeleteObject calls the OpenStack delete object API using
//previously obtained token.
//
//Note from API doc: "A DELETE to a versioned object removes the current version
//of the object and replaces it with the next-most current version, moving it
//from the non-current container to the current." .. "If you want to completely
//remove an object and you have five total versions of it, you must DELETE it
//five times."
func DeleteObject(session *openstack.Session, url string) (err error) {
	resp, err := session.Delete(url, nil, nil)
	if err != nil {
		return err
	}
	return util.CheckHTTPResponseStatusCode(resp)
}
开发者ID:hbellur,项目名称:golang-client,代码行数:15,代码来源:objectstorage.go


示例4: PutObject

//PutObject calls the OpenStack create object API using previously
//obtained token.
//url can be regular storage or CDN-enabled storage URL.
func PutObject(session *openstack.Session, fContent *[]byte, url string, headers http.Header) (err error) {
	resp, err := session.Put(url, nil, &headers, fContent)
	if err != nil {
		return err
	}
	return util.CheckHTTPResponseStatusCode(resp)
}
开发者ID:hbellur,项目名称:golang-client,代码行数:10,代码来源:objectstorage.go


示例5: SetObjectMeta

//SetObjectMeta calls the OpenStack API to create/update meta data for
//object using previously obtained token.
func SetObjectMeta(session *openstack.Session, url string, headers http.Header) (err error) {
	// headers.Add("X-Auth-Token", token)
	resp, err := session.Post(url, nil, &headers, zeroByte)
	if err != nil {
		return err
	}
	return util.CheckHTTPResponseStatusCode(resp)
}
开发者ID:hbellur,项目名称:golang-client,代码行数:10,代码来源:objectstorage.go


示例6: CopyObject

//CopyObject calls the OpenStack copy object API using previously obtained
//token.  Note from API doc: "The destination container must exist before
//attempting the copy."
func CopyObject(session *openstack.Session, srcURL, destURL string) (err error) {
	var headers http.Header = http.Header{}
	headers.Add("Destination", destURL)
	resp, err := session.Request("COPY", srcURL, nil, &headers, zeroByte)
	if err != nil {
		return err
	}
	return util.CheckHTTPResponseStatusCode(resp)
}
开发者ID:hbellur,项目名称:golang-client,代码行数:12,代码来源:objectstorage.go


示例7: GetObject

//GetObject calls the OpenStack retrieve object API using previously
//obtained token. It returns http.Header, object / file content downloaded
//from the server, and err.
//
//Since this implementation of GetObject retrieves header info, it
//effectively executes GetObjectMeta also in addition to getting the
//object content.
func GetObject(session *openstack.Session, url string) (http.Header, []byte, error) {
	resp, err := session.Get(url, nil, nil)
	if err != nil {
		return nil, nil, err
	}
	if err = util.CheckHTTPResponseStatusCode(resp); err != nil {
		return nil, nil, err
	}
	var body []byte
	if body, err = ioutil.ReadAll(resp.Body); err != nil {
		return nil, nil, err
	}
	resp.Body.Close()
	return resp.Header, body, nil
}
开发者ID:hbellur,项目名称:golang-client,代码行数:22,代码来源:objectstorage.go



注:本文中的git/openstack/org/stackforge/golang-client/git/openstack.Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang testUtil.Equals函数代码示例发布时间:2022-05-24
下一篇:
Golang revel.Validation类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap