feat: 添加 Shares 公平共享类型和 SharesService
包含 SharesRespMsg、AssocSharesObjWrap、TRES 明细等类型。SharesService 提供 GetShares 方法,支持按 accounts 和 users 查询。 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
44
internal/slurm/slurm_shares.go
Normal file
44
internal/slurm/slurm_shares.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package slurm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// GetSharesOptions specifies optional parameters for GetShares.
|
||||
type GetSharesOptions struct {
|
||||
Accounts *string `url:"accounts,omitempty"`
|
||||
Users *string `url:"users,omitempty"`
|
||||
}
|
||||
|
||||
// GetShares retrieves fairshare shares information.
|
||||
func (s *SharesService) GetShares(ctx context.Context, opts *GetSharesOptions) (*OpenapiSharesResp, *Response, error) {
|
||||
path := "slurm/v0.0.40/shares"
|
||||
req, err := s.client.NewRequest("GET", path, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if opts != nil {
|
||||
u, parseErr := url.Parse(req.URL.String())
|
||||
if parseErr != nil {
|
||||
return nil, nil, parseErr
|
||||
}
|
||||
q := u.Query()
|
||||
if opts.Accounts != nil {
|
||||
q.Set("accounts", *opts.Accounts)
|
||||
}
|
||||
if opts.Users != nil {
|
||||
q.Set("users", *opts.Users)
|
||||
}
|
||||
u.RawQuery = q.Encode()
|
||||
req.URL = u
|
||||
}
|
||||
|
||||
var result OpenapiSharesResp
|
||||
resp, err := s.client.Do(ctx, req, &result)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return &result, resp, nil
|
||||
}
|
||||
Reference in New Issue
Block a user