Update API templates using list params (#352)
This commit is contained in:
1 parent
b7524f8cfb
commit
c1171e0cc6
5 files changed
+70
-99
No files matched your search
+13
-18
@@ -294,8 +294,11 @@ func (c *Client) AddHostSets(ctx context.Context, targetId string, version uint3
|
||||
if targetId == "" {
|
||||
return nil, nil, fmt.Errorf("empty targetId value passed into AddHostSets request")
|
||||
}
|
||||
if len(hostSetIds) == 0 {
|
||||
return nil, nil, errors.New("empty hostSetIds passed into AddHostSets request")
|
||||
}
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
return nil, nil, errors.New("nil client")
|
||||
}
|
||||
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
@@ -318,10 +321,7 @@ func (c *Client) AddHostSets(ctx context.Context, targetId string, version uint3
|
||||
}
|
||||
|
||||
opts.postMap["version"] = version
|
||||
|
||||
if len(hostSetIds) > 0 {
|
||||
opts.postMap["host_set_ids"] = hostSetIds
|
||||
}
|
||||
opts.postMap["host_set_ids"] = hostSetIds
|
||||
|
||||
req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("targets/%s:add-host-sets", targetId), opts.postMap, apiOpts...)
|
||||
if err != nil {
|
||||
@@ -356,8 +356,9 @@ func (c *Client) SetHostSets(ctx context.Context, targetId string, version uint3
|
||||
if targetId == "" {
|
||||
return nil, nil, fmt.Errorf("empty targetId value passed into SetHostSets request")
|
||||
}
|
||||
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
return nil, nil, errors.New("nil client")
|
||||
}
|
||||
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
@@ -380,13 +381,7 @@ func (c *Client) SetHostSets(ctx context.Context, targetId string, version uint3
|
||||
}
|
||||
|
||||
opts.postMap["version"] = version
|
||||
|
||||
if len(hostSetIds) > 0 {
|
||||
opts.postMap["host_set_ids"] = hostSetIds
|
||||
} else if hostSetIds != nil {
|
||||
// In this function, a non-nil but empty list means clear out
|
||||
opts.postMap["host_set_ids"] = nil
|
||||
}
|
||||
opts.postMap["host_set_ids"] = hostSetIds
|
||||
|
||||
req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("targets/%s:set-host-sets", targetId), opts.postMap, apiOpts...)
|
||||
if err != nil {
|
||||
@@ -421,8 +416,11 @@ func (c *Client) RemoveHostSets(ctx context.Context, targetId string, version ui
|
||||
if targetId == "" {
|
||||
return nil, nil, fmt.Errorf("empty targetId value passed into RemoveHostSets request")
|
||||
}
|
||||
if len(hostSetIds) == 0 {
|
||||
return nil, nil, errors.New("empty hostSetIds passed into RemoveHostSets request")
|
||||
}
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
return nil, nil, errors.New("nil client")
|
||||
}
|
||||
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
@@ -445,10 +443,7 @@ func (c *Client) RemoveHostSets(ctx context.Context, targetId string, version ui
|
||||
}
|
||||
|
||||
opts.postMap["version"] = version
|
||||
|
||||
if len(hostSetIds) > 0 {
|
||||
opts.postMap["host_set_ids"] = hostSetIds
|
||||
}
|
||||
opts.postMap["host_set_ids"] = hostSetIds
|
||||
|
||||
req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("targets/%s:remove-host-sets", targetId), opts.postMap, apiOpts...)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user