本文整理汇总了Golang中git/curoverse/com/arvados/git/sdk/go/arvadosclient.ArvadosClient类的典型用法代码示例。如果您正苦于以下问题:Golang ArvadosClient类的具体用法?Golang ArvadosClient怎么用?Golang ArvadosClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArvadosClient类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: UserIsAdmin
func UserIsAdmin(arv arvadosclient.ArvadosClient) (is_admin bool, err error) {
type user struct {
IsAdmin bool `json:"is_admin"`
}
var u user
err = arv.Call("GET", "users", "", "current", nil, &u)
return u.IsAdmin, err
}
开发者ID:WangZhenfei,项目名称:arvados,代码行数:8,代码来源:util.go
示例2: NumberItemsAvailable
// Returns the total count of a particular type of resource
//
// resource - the arvados resource to count
// return
// count - the number of items of type resource the api server reports, if no error
// err - error accessing the resource, or nil if no error
func NumberItemsAvailable(client arvadosclient.ArvadosClient, resource string) (count int, err error) {
var response struct {
ItemsAvailable int `json:"items_available"`
}
sdkParams := arvadosclient.Dict{"limit": 0}
err = client.List(resource, sdkParams, &response)
if err == nil {
count = response.ItemsAvailable
}
return
}
开发者ID:WangZhenfei,项目名称:arvados,代码行数:17,代码来源:util.go
示例3: setupKeepClient
// setup keepclient using the config provided
func setupKeepClient(config apiConfig, keepServicesJSON string, isDst bool, replications int, srcBlobSignatureTTL time.Duration) (kc *keepclient.KeepClient, blobSignatureTTL time.Duration, err error) {
arv := arvadosclient.ArvadosClient{
ApiToken: config.APIToken,
ApiServer: config.APIHost,
ApiInsecure: config.APIHostInsecure,
Client: &http.Client{Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.APIHostInsecure}}},
External: config.ExternalClient,
}
// if keepServicesJSON is provided, use it to load services; else, use DiscoverKeepServers
if keepServicesJSON == "" {
kc, err = keepclient.MakeKeepClient(&arv)
if err != nil {
return nil, 0, err
}
} else {
kc = keepclient.New(&arv)
err = kc.LoadKeepServicesFromJSON(keepServicesJSON)
if err != nil {
return kc, 0, err
}
}
if isDst {
// Get default replications value from destination, if it is not already provided
if replications == 0 {
value, err := arv.Discovery("defaultCollectionReplication")
if err == nil {
replications = int(value.(float64))
} else {
return nil, 0, err
}
}
kc.Want_replicas = replications
}
// If srcBlobSignatureTTL is not provided, get it from API server discovery doc
blobSignatureTTL = srcBlobSignatureTTL
if !isDst && srcBlobSignatureTTL == 0 {
value, err := arv.Discovery("blobSignatureTtl")
if err == nil {
blobSignatureTTL = time.Duration(int(value.(float64))) * time.Second
} else {
return nil, 0, err
}
}
return kc, blobSignatureTTL, nil
}
开发者ID:pombredanne,项目名称:arvados,代码行数:52,代码来源:keep-rsync.go
示例4: New
// New func creates a new KeepClient struct.
// This func does not discover keep servers. It is the caller's responsibility.
func New(arv *arvadosclient.ArvadosClient) *KeepClient {
defaultReplicationLevel := 2
value, err := arv.Discovery("defaultCollectionReplication")
if err == nil {
v, ok := value.(float64)
if ok && v > 0 {
defaultReplicationLevel = int(v)
}
}
kc := &KeepClient{
Arvados: arv,
Want_replicas: defaultReplicationLevel,
Client: &http.Client{Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: arv.ApiInsecure}}},
Retries: 2,
}
return kc
}
开发者ID:pombredanne,项目名称:arvados,代码行数:21,代码来源:keepclient.go
示例5: setupKeepClient
// setup keepclient using the config provided
func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL time.Duration) (kc *keepclient.KeepClient, ttl time.Duration, err error) {
arv := arvadosclient.ArvadosClient{
ApiToken: config.APIToken,
ApiServer: config.APIHost,
ApiInsecure: config.APIHostInsecure,
Client: &http.Client{Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.APIHostInsecure}}},
External: config.ExternalClient,
}
// if keepServicesJSON is provided, use it to load services; else, use DiscoverKeepServers
if keepServicesJSON == "" {
kc, err = keepclient.MakeKeepClient(&arv)
if err != nil {
return
}
} else {
kc = keepclient.New(&arv)
err = kc.LoadKeepServicesFromJSON(keepServicesJSON)
if err != nil {
return
}
}
// Get if blobSignatureTTL is not provided
ttl = blobSignatureTTL
if blobSignatureTTL == 0 {
value, err := arv.Discovery("blobSignatureTtl")
if err == nil {
ttl = time.Duration(int(value.(float64))) * time.Second
} else {
return nil, 0, err
}
}
return
}
开发者ID:pombredanne,项目名称:arvados,代码行数:38,代码来源:keep-block-check.go
注:本文中的git/curoverse/com/arvados/git/sdk/go/arvadosclient.ArvadosClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论