本文整理汇总了Golang中github.com/aerofs/aerofs-sdk-golang/aerofsapi.Client类的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewDeviceClient
// Return an existing device client given a deviceId
func NewDeviceClient(c *api.Client, deviceId string) (*DeviceClient, error) {
body, _, err := c.GetDeviceMetadata(deviceId)
if err != nil {
return nil, err
}
device := Device{}
err = json.Unmarshal(body, &device)
return &DeviceClient{c, device}, err
}
示例2: ListSharedFolders
// Retrieve a list of SharedFolder member descriptors
// TODO : Should an Etag be return for each one?
func ListSharedFolders(c *api.Client, sid string, etags []string) ([]SharedFolder, error) {
body, _, err := c.ListSharedFolders(sid, etags)
if err != nil {
return nil, err
}
sfs := []SharedFolder{}
err = json.Unmarshal(body, &sfs)
if err != nil {
return nil, errors.New("Unable to demarshal the list of retrieved SharedFolders")
}
return sfs, nil
}
示例3: ListGroups
// List all groups
func ListGroups(c *api.Client, offset, results int) (*[]Group, error) {
body, _, err := c.ListGroups(offset, results)
if err != nil {
return nil, err
}
groups := []Group{}
err = json.Unmarshal(body, &groups)
if err != nil {
return nil, errors.New("Unable to unmarshal list of groups")
}
return &groups, nil
}
示例4: GetSFMemberClient
// Return an existing SFMemberClient given its shared folder and user email
func GetSFMemberClient(c *api.Client, sid, email string, etags []string) (*SFMemberClient, error) {
body, header, err := c.GetSFMember(sid, email, etags)
if err != nil {
return nil, err
}
sfmClient := SFMemberClient{APIClient: c, Etag: header.Get("ETag"), Desc: SFMember{Sid: sid, Email: email}}
err = json.Unmarshal(body, &sfmClient.Desc)
if err != nil {
return nil, errors.New("Unable to unmarshal retrieved SFMember")
}
return &sfmClient, nil
}
示例5: ListDevices
// Retrieve a list of existing Device descriptors
func ListDevices(c *api.Client, email string) ([]Device, error) {
body, _, err := c.ListDevices(email)
if err != nil {
return nil, err
}
devices := []Device{}
err = json.Unmarshal(body, &devices)
if err != nil {
return nil, errors.New("Unable to demarshal list of devices")
}
return devices, err
}
示例6: GetSharedFolderClient
// Retrieve an existing shared folder
func GetSharedFolderClient(c *api.Client, sid string, etags []string) (*SharedFolderClient, error) {
body, header, err := c.ListSharedFolderMetadata(sid, etags)
if err != nil {
return nil, err
}
sfClient := SharedFolderClient{APIClient: c}
err = json.Unmarshal(body, &sfClient.Desc)
if err != nil {
return nil, errors.New("Unable to unmarshal retrieved Shared Folder")
}
sfClient.Etag = header.Get("ETag")
return &sfClient, nil
}
示例7: ListUsers
// Get a list of existing user descriptors
func ListUsers(client *api.Client, limit int) (*[]User, error) {
body, _, err := client.ListUsers(limit, nil, nil)
if err != nil {
return nil, err
}
userResp := userListResponse{}
err = json.Unmarshal(body, &userResp)
if err != nil {
return nil, errors.New("Unable to unmarshal a retrieved list of users")
}
return &userResp.Users, nil
}
示例8: CreateGroupClient
// Create a group
func CreateGroupClient(c *api.Client, groupName string) (*GroupClient, error) {
body, _, err := c.CreateGroup(groupName)
if err != nil {
return nil, err
}
g := GroupClient{APIClient: c}
err = json.Unmarshal(body, &g.Desc)
if err != nil {
return nil, errors.New("Unable to unmarshal created group")
}
return &g, nil
}
示例9: NewGroupClient
// Retrieve an existing group
func NewGroupClient(c *api.Client, groupId string) (*GroupClient, error) {
body, _, err := c.GetGroup(groupId)
if err != nil {
return nil, err
}
g := GroupClient{APIClient: c}
err = json.Unmarshal(body, &g.Desc)
if err != nil {
return nil, errors.New("Unable to unmarshal existing group")
}
return &g, nil
}
示例10: CreateSharedFolderClient
// Create a new shared folder and return a client associated with it
func CreateSharedFolderClient(c *api.Client, name string) (*SharedFolderClient, error) {
body, _, err := c.CreateSharedFolder(name)
if err != nil {
return nil, err
}
sfClient := SharedFolderClient{APIClient: c}
err = json.Unmarshal(body, &sfClient.Desc)
if err != nil {
return nil, errors.New("Unable to unmarshal retrieved SharedFolder")
}
return &sfClient, nil
}
示例11: CreateUserClient
// Create a new user and return a UserClient tied to the APIClient argument
func CreateUserClient(client *api.Client, email, firstName, lastName string) (*UserClient, error) {
body, _, err := client.CreateUser(email, firstName, lastName)
if err != nil {
return nil, err
}
u := User{}
err = json.Unmarshal(body, &u)
if err != nil {
return nil, errors.New("Unable to unmarshal new User")
}
return &UserClient{client, u}, nil
}
示例12: ListSFMember
// Retrieve a list of SharedFolder member descriptors
// TOD : Should an Etag be return for each one?
func ListSFMember(c *api.Client, sid string, etags []string) ([]SFMember, error) {
body, _, err := c.ListSFMembers(sid, etags)
if err != nil {
return nil, err
}
sfmembers := []SFMember{}
err = json.Unmarshal(body, &sfmembers)
if err != nil {
return nil, errors.New("Unable to demarshal the list of retrieved SharedFolder members")
}
for _, v := range sfmembers {
v.Sid = sid
}
return sfmembers, nil
}
示例13: NewFileClient
// Construct a FileClient given a file identifier and APIClient
func NewFileClient(c *api.Client, fileId string, fields []string) (*FileClient, error) {
body, header, err := c.GetFileMetadata(fileId, fields)
if err != nil {
return nil, err
}
f := FileClient{APIClient: c, OnDemand: fields}
err = json.Unmarshal(body, &f.Desc)
if err != nil {
return nil, errors.New("Unable to unmarshal existing File")
}
f.Desc.Etag = header.Get("ETag")
return &f, nil
}
示例14: GetUserClient
// Given an existing user's email, return a client for said user
func GetUserClient(client *api.Client, email string) (*UserClient, error) {
body, _, err := client.GetUser(email)
if err != nil {
return nil, err
}
u := UserClient{APIClient: client}
err = json.Unmarshal(body, &u.Desc)
if err != nil {
fmt.Println(err)
return nil, errors.New("Unable to unmarshal new User")
}
return &u, nil
}