package slurm import ( "context" "fmt" "net/url" "strconv" ) // GetPartitionsOptions specifies optional parameters for GetPartitions. type GetPartitionsOptions struct { UpdateTime *int64 `url:"update_time,omitempty"` } // GetPartitions lists all partitions. func (s *PartitionsService) GetPartitions(ctx context.Context, opts *GetPartitionsOptions) (*OpenapiPartitionResp, *Response, error) { path := "slurm/v0.0.40/partitions" 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.UpdateTime != nil { q.Set("update_time", strconv.FormatInt(*opts.UpdateTime, 10)) } u.RawQuery = q.Encode() req.URL = u } var result OpenapiPartitionResp resp, err := s.client.Do(ctx, req, &result) if err != nil { return nil, resp, err } return &result, resp, nil } // GetPartition gets a single partition by name. func (s *PartitionsService) GetPartition(ctx context.Context, partitionName string, opts *GetPartitionsOptions) (*OpenapiPartitionResp, *Response, error) { path := fmt.Sprintf("slurm/v0.0.40/partition/%s", partitionName) 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.UpdateTime != nil { q.Set("update_time", strconv.FormatInt(*opts.UpdateTime, 10)) } u.RawQuery = q.Encode() req.URL = u } var result OpenapiPartitionResp resp, err := s.client.Do(ctx, req, &result) if err != nil { return nil, resp, err } return &result, resp, nil }