Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
126 lines
3.2 KiB
Go
126 lines
3.2 KiB
Go
package slurm
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/url"
|
|
)
|
|
|
|
// GetWckeysOptions specifies optional parameters for GetWckeys.
|
|
type GetWckeysOptions struct {
|
|
Cluster *string `url:"cluster,omitempty"`
|
|
Format *string `url:"format,omitempty"`
|
|
ID *string `url:"id,omitempty"`
|
|
Name *string `url:"name,omitempty"`
|
|
OnlyDefaults *string `url:"only_defaults,omitempty"`
|
|
UsageEnd *string `url:"usage_end,omitempty"`
|
|
UsageStart *string `url:"usage_start,omitempty"`
|
|
User *string `url:"user,omitempty"`
|
|
WithUsage *string `url:"with_usage,omitempty"`
|
|
WithDeleted *string `url:"with_deleted,omitempty"`
|
|
}
|
|
|
|
// GetWckeys lists all wckeys.
|
|
func (s *SlurmdbWckeysService) GetWckeys(ctx context.Context, opts *GetWckeysOptions) (*OpenapiWckeyResp, *Response, error) {
|
|
path := "slurmdb/v0.0.40/wckeys"
|
|
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.Cluster != nil {
|
|
q.Set("cluster", *opts.Cluster)
|
|
}
|
|
if opts.Format != nil {
|
|
q.Set("format", *opts.Format)
|
|
}
|
|
if opts.ID != nil {
|
|
q.Set("id", *opts.ID)
|
|
}
|
|
if opts.Name != nil {
|
|
q.Set("name", *opts.Name)
|
|
}
|
|
if opts.OnlyDefaults != nil {
|
|
q.Set("only_defaults", *opts.OnlyDefaults)
|
|
}
|
|
if opts.UsageEnd != nil {
|
|
q.Set("usage_end", *opts.UsageEnd)
|
|
}
|
|
if opts.UsageStart != nil {
|
|
q.Set("usage_start", *opts.UsageStart)
|
|
}
|
|
if opts.User != nil {
|
|
q.Set("user", *opts.User)
|
|
}
|
|
if opts.WithUsage != nil {
|
|
q.Set("with_usage", *opts.WithUsage)
|
|
}
|
|
if opts.WithDeleted != nil {
|
|
q.Set("with_deleted", *opts.WithDeleted)
|
|
}
|
|
u.RawQuery = q.Encode()
|
|
req.URL = u
|
|
}
|
|
|
|
var result OpenapiWckeyResp
|
|
resp, err := s.client.Do(ctx, req, &result)
|
|
if err != nil {
|
|
return nil, resp, err
|
|
}
|
|
return &result, resp, nil
|
|
}
|
|
|
|
// GetWckey gets a single wckey by ID.
|
|
func (s *SlurmdbWckeysService) GetWckey(ctx context.Context, wckeyID string) (*OpenapiWckeyResp, *Response, error) {
|
|
path := fmt.Sprintf("slurmdb/v0.0.40/wckey/%s", wckeyID)
|
|
req, err := s.client.NewRequest("GET", path, nil)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
var result OpenapiWckeyResp
|
|
resp, err := s.client.Do(ctx, req, &result)
|
|
if err != nil {
|
|
return nil, resp, err
|
|
}
|
|
return &result, resp, nil
|
|
}
|
|
|
|
// PostWckeys adds wckeys.
|
|
func (s *SlurmdbWckeysService) PostWckeys(ctx context.Context, body *OpenapiWckeyResp) (*OpenapiResp, *Response, error) {
|
|
path := "slurmdb/v0.0.40/wckeys"
|
|
req, err := s.client.NewRequest("POST", path, body)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
var result OpenapiResp
|
|
resp, err := s.client.Do(ctx, req, &result)
|
|
if err != nil {
|
|
return nil, resp, err
|
|
}
|
|
return &result, resp, nil
|
|
}
|
|
|
|
// DeleteWckey deletes a wckey by ID.
|
|
func (s *SlurmdbWckeysService) DeleteWckey(ctx context.Context, wckeyID string) (*OpenapiWckeyRemovedResp, *Response, error) {
|
|
path := fmt.Sprintf("slurmdb/v0.0.40/wckey/%s", wckeyID)
|
|
req, err := s.client.NewRequest("DELETE", path, nil)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
var result OpenapiWckeyRemovedResp
|
|
resp, err := s.client.Do(ctx, req, &result)
|
|
if err != nil {
|
|
return nil, resp, err
|
|
}
|
|
return &result, resp, nil
|
|
}
|