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
@@ -472,8 +472,11 @@ func (c *Client) {{ $fullName }}(ctx context.Context, {{ $input.ResourceFunction
|
||||
if {{ $input.ResourceFunctionArg }} == "" {
|
||||
return nil, nil, fmt.Errorf("empty {{ $input.ResourceFunctionArg }} value passed into {{ $fullName }} request")
|
||||
}
|
||||
{{ if ( not ( eq $op "Set" ) ) }}if len({{ $value }}) == 0 {
|
||||
return nil, nil, errors.New("empty {{ $value }} passed into {{ $fullName }} request")
|
||||
}{{ end }}
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
return nil, nil, errors.New("nil client")
|
||||
}
|
||||
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
@@ -497,14 +500,7 @@ func (c *Client) {{ $fullName }}(ctx context.Context, {{ $input.ResourceFunction
|
||||
}
|
||||
{{ end }}
|
||||
opts.postMap["version"] = version
|
||||
|
||||
if len({{ $value }}) > 0 {
|
||||
opts.postMap["{{ snakeCase $value }}"] = {{ $value }}
|
||||
}{{ if ( eq $op "Set" ) }} else if {{ $value }} != nil {
|
||||
// In this function, a non-nil but empty list means clear out
|
||||
opts.postMap["{{ snakeCase $value }}"] = nil
|
||||
}
|
||||
{{ end }}
|
||||
opts.postMap["{{ snakeCase $value }}"] = {{ $value }}
|
||||
|
||||
req, err := c.client.NewRequest(ctx, "POST", {{ $resPath }}, opts.postMap, apiOpts...)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user