当前位置: 首页>>代码示例>>Golang>>正文


Golang BackupsMetadataResult.ID方法代码示例

本文整理汇总了Golang中github.com/juju/juju/apiserver/params.BackupsMetadataResult.ID方法的典型用法代码示例。如果您正苦于以下问题:Golang BackupsMetadataResult.ID方法的具体用法?Golang BackupsMetadataResult.ID怎么用?Golang BackupsMetadataResult.ID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/juju/juju/apiserver/params.BackupsMetadataResult的用法示例。


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

示例1: ResultFromMetadata

// ResultFromMetadata updates the result with the information in the
// metadata value.
func ResultFromMetadata(meta *backups.Metadata) params.BackupsMetadataResult {
	var result params.BackupsMetadataResult

	result.ID = meta.ID()

	result.Checksum = meta.Checksum()
	result.ChecksumFormat = meta.ChecksumFormat()
	result.Size = meta.Size()
	if meta.Stored() != nil {
		result.Stored = *(meta.Stored())
	}

	result.Started = meta.Started
	if meta.Finished != nil {
		result.Finished = *meta.Finished
	}
	result.Notes = meta.Notes

	result.Environment = meta.Origin.Environment
	result.Machine = meta.Origin.Machine
	result.Hostname = meta.Origin.Hostname
	result.Version = meta.Origin.Version

	return result
}
开发者ID:imoapps,项目名称:juju,代码行数:27,代码来源:backups.go

示例2: ResultFromMetadata

// ResultFromMetadata updates the result with the information in the
// metadata value.
func ResultFromMetadata(meta *backups.Metadata) params.BackupsMetadataResult {
	var result params.BackupsMetadataResult

	result.ID = meta.ID()

	result.Checksum = meta.Checksum()
	result.ChecksumFormat = meta.ChecksumFormat()
	result.Size = meta.Size()
	if meta.Stored() != nil {
		result.Stored = *(meta.Stored())
	}

	result.Started = meta.Started
	if meta.Finished != nil {
		result.Finished = *meta.Finished
	}
	result.Notes = meta.Notes

	result.Model = meta.Origin.Model
	result.Machine = meta.Origin.Machine
	result.Hostname = meta.Origin.Hostname
	result.Version = meta.Origin.Version
	result.Series = meta.Origin.Series

	// TODO(wallyworld) - remove these ASAP
	// These are only used by the restore CLI when re-bootstrapping.
	// We will use a better solution but the way restore currently
	// works, we need them and they are no longer available via
	// bootstrap config. We will need to ifx how re-bootstrap deals
	// with these keys to address the issue.
	result.CACert = meta.CACert
	result.CAPrivateKey = meta.CAPrivateKey

	return result
}
开发者ID:bac,项目名称:juju,代码行数:37,代码来源:backups.go

示例3: Upload

// Upload sends the backup archive to remote storage.
func (c *Client) Upload(archive io.Reader, meta params.BackupsMetadataResult) (string, error) {
	// Empty out some of the metadata.
	meta.ID = ""
	meta.Stored = time.Time{}

	// Send the request.
	_, resp, err := c.http.SendHTTPRequestReader("backups", archive, &meta, "juju-backup.tar.gz")
	if err != nil {
		return "", errors.Annotate(err, "while sending HTTP request")
	}

	// Handle the response.
	if resp.StatusCode == http.StatusOK {
		var result params.BackupsMetadataResult
		if err := apihttp.ExtractJSONResult(resp, &result); err != nil {
			return "", errors.Annotate(err, "while extracting result")
		}
		return result.ID, nil
	} else {
		failure, err := apihttp.ExtractAPIError(resp)
		if err != nil {
			return "", errors.Annotate(err, "while extracting failure")
		}
		return "", errors.Trace(failure)
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:27,代码来源:upload.go

示例4: Upload

// Upload sends the backup archive to remote storage.
func (c *Client) Upload(archive io.ReadSeeker, meta params.BackupsMetadataResult) (string, error) {
	// Empty out some of the metadata.
	meta.ID = ""
	meta.Stored = time.Time{}

	req, err := http.NewRequest("PUT", "/backups", nil)
	if err != nil {
		return "", errors.Trace(err)
	}
	body, contentType, err := httpattachment.NewBody(archive, meta, "juju-backup.tar.gz")
	if err != nil {
		return "", errors.Annotatef(err, "cannot create multipart body")
	}
	req.Header.Set("Content-Type", contentType)
	var result params.BackupsMetadataResult
	if err := c.client.Do(req, body, &result); err != nil {
		return "", errors.Trace(err)
	}
	return result.ID, nil
}
开发者ID:imoapps,项目名称:juju,代码行数:21,代码来源:upload.go


注:本文中的github.com/juju/juju/apiserver/params.BackupsMetadataResult.ID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。