Version can be passed through request body (#281)

* Scopes inline version into update request body.

* Users inline version into update request body.

* Group inline version into update and add|set|remove member request body.

* Role inline version into update and add|set|remove grant|principal request body.

* Auth method inline version into update request body.

* Auth Account inline version into update request body.

* host catalog version is inlined for update.

* Gen after merge.

* Submitting template changes for version handling.
This commit is contained in:
Todd Knight authored and GitHub committed 2020-08-18 17:38:38 -07:00
1 parent e20c150617
commit d86e58476f
62 files changed
+1629 -2137

No files matched your search

+2 -5
View File
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"net/url"
"time"
"github.com/kr/pretty"
@@ -127,15 +126,13 @@ func (c *AccountsClient) Update(ctx context.Context, authMethodId string, accoun
version = existingTarget.Version
}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", fmt.Sprintf("auth-methods/%s/accounts/%s", authMethodId, accountId), opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)
+2 -5
View File
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"net/url"
"time"
"github.com/kr/pretty"
@@ -121,15 +120,13 @@ func (c *AuthMethodsClient) Update(ctx context.Context, authMethodId string, ver
version = existingTarget.Version
}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", fmt.Sprintf("auth-methods/%s", authMethodId), opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)
+8 -17
View File
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"net/url"
"time"
"github.com/kr/pretty"
@@ -116,15 +115,13 @@ func (c *GroupsClient) Update(ctx context.Context, groupId string, version uint3
version = existingTarget.Version
}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", fmt.Sprintf("groups/%s", groupId), opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)
@@ -228,6 +225,8 @@ func (c *GroupsClient) AddMembers(ctx context.Context, groupId string, version u
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(memberIds) > 0 {
opts.valueMap["member_ids"] = memberIds
}
@@ -237,10 +236,6 @@ func (c *GroupsClient) AddMembers(ctx context.Context, groupId string, version u
return nil, nil, fmt.Errorf("error creating AddMembers request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during AddMembers call: %w", err)
@@ -282,6 +277,8 @@ func (c *GroupsClient) SetMembers(ctx context.Context, groupId string, version u
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(memberIds) > 0 {
opts.valueMap["member_ids"] = memberIds
} else if memberIds != nil {
@@ -294,10 +291,6 @@ func (c *GroupsClient) SetMembers(ctx context.Context, groupId string, version u
return nil, nil, fmt.Errorf("error creating SetMembers request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during SetMembers call: %w", err)
@@ -339,6 +332,8 @@ func (c *GroupsClient) RemoveMembers(ctx context.Context, groupId string, versio
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(memberIds) > 0 {
opts.valueMap["member_ids"] = memberIds
}
@@ -348,10 +343,6 @@ func (c *GroupsClient) RemoveMembers(ctx context.Context, groupId string, versio
return nil, nil, fmt.Errorf("error creating RemoveMembers request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during RemoveMembers call: %w", err)
+2 -5
View File
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"net/url"
"time"
"github.com/kr/pretty"
@@ -126,15 +125,13 @@ func (c *HostsClient) Update(ctx context.Context, hostCatalogId string, hostId s
version = existingTarget.Version
}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", fmt.Sprintf("host-catalogs/%s/hosts/%s", hostCatalogId, hostId), opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)
+2 -5
View File
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"net/url"
"time"
"github.com/kr/pretty"
@@ -121,15 +120,13 @@ func (c *HostCatalogsClient) Update(ctx context.Context, hostCatalogId string, v
version = existingTarget.Version
}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", fmt.Sprintf("host-catalogs/%s", hostCatalogId), opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)
+8 -17
View File
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"net/url"
"time"
"github.com/kr/pretty"
@@ -127,15 +126,13 @@ func (c *HostSetsClient) Update(ctx context.Context, hostCatalogId string, hostS
version = existingTarget.Version
}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", fmt.Sprintf("host-catalogs/%s/host-sets/%s", hostCatalogId, hostSetId), opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)
@@ -250,6 +247,8 @@ func (c *HostSetsClient) AddHosts(ctx context.Context, hostCatalogId string, hos
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(hostIds) > 0 {
opts.valueMap["host_ids"] = hostIds
}
@@ -259,10 +258,6 @@ func (c *HostSetsClient) AddHosts(ctx context.Context, hostCatalogId string, hos
return nil, nil, fmt.Errorf("error creating AddHosts request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during AddHosts call: %w", err)
@@ -307,6 +302,8 @@ func (c *HostSetsClient) SetHosts(ctx context.Context, hostCatalogId string, hos
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(hostIds) > 0 {
opts.valueMap["host_ids"] = hostIds
} else if hostIds != nil {
@@ -319,10 +316,6 @@ func (c *HostSetsClient) SetHosts(ctx context.Context, hostCatalogId string, hos
return nil, nil, fmt.Errorf("error creating SetHosts request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during SetHosts call: %w", err)
@@ -367,6 +360,8 @@ func (c *HostSetsClient) RemoveHosts(ctx context.Context, hostCatalogId string,
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(hostIds) > 0 {
opts.valueMap["host_ids"] = hostIds
}
@@ -376,10 +371,6 @@ func (c *HostSetsClient) RemoveHosts(ctx context.Context, hostCatalogId string,
return nil, nil, fmt.Errorf("error creating RemoveHosts request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during RemoveHosts call: %w", err)
+3 -8
View File
@@ -363,15 +363,13 @@ func (c *{{ .ClientName }}Client) Update(ctx context.Context, {{ range .Resource
}
{{ end }}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", {{ .ResourcePath }}, opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)
@@ -429,6 +427,7 @@ func (c *{{ $input.ClientName }}Client) {{ $fullName }}(ctx context.Context, {{
version = existingTarget.Version
}
{{ end }}
opts.valueMap["version"] = version
if len({{ $value }}) > 0 {
opts.valueMap["{{ snakeCase $value }}"] = {{ $value }}
@@ -443,10 +442,6 @@ func (c *{{ $input.ClientName }}Client) {{ $fullName }}(ctx context.Context, {{
return nil, nil, fmt.Errorf("error creating {{ $fullName }} request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during {{ $fullName }} call: %w", err)
+14 -29
View File
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"net/url"
"time"
"github.com/kr/pretty"
@@ -119,15 +118,13 @@ func (c *RolesClient) Update(ctx context.Context, roleId string, version uint32,
version = existingTarget.Version
}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", fmt.Sprintf("roles/%s", roleId), opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)
@@ -231,6 +228,8 @@ func (c *RolesClient) AddGrants(ctx context.Context, roleId string, version uint
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(grantStrings) > 0 {
opts.valueMap["grant_strings"] = grantStrings
}
@@ -240,10 +239,6 @@ func (c *RolesClient) AddGrants(ctx context.Context, roleId string, version uint
return nil, nil, fmt.Errorf("error creating AddGrants request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during AddGrants call: %w", err)
@@ -285,6 +280,8 @@ func (c *RolesClient) AddPrincipals(ctx context.Context, roleId string, version
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(principalIds) > 0 {
opts.valueMap["principal_ids"] = principalIds
}
@@ -294,10 +291,6 @@ func (c *RolesClient) AddPrincipals(ctx context.Context, roleId string, version
return nil, nil, fmt.Errorf("error creating AddPrincipals request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during AddPrincipals call: %w", err)
@@ -339,6 +332,8 @@ func (c *RolesClient) SetGrants(ctx context.Context, roleId string, version uint
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(grantStrings) > 0 {
opts.valueMap["grant_strings"] = grantStrings
} else if grantStrings != nil {
@@ -351,10 +346,6 @@ func (c *RolesClient) SetGrants(ctx context.Context, roleId string, version uint
return nil, nil, fmt.Errorf("error creating SetGrants request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during SetGrants call: %w", err)
@@ -396,6 +387,8 @@ func (c *RolesClient) SetPrincipals(ctx context.Context, roleId string, version
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(principalIds) > 0 {
opts.valueMap["principal_ids"] = principalIds
} else if principalIds != nil {
@@ -408,10 +401,6 @@ func (c *RolesClient) SetPrincipals(ctx context.Context, roleId string, version
return nil, nil, fmt.Errorf("error creating SetPrincipals request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during SetPrincipals call: %w", err)
@@ -453,6 +442,8 @@ func (c *RolesClient) RemoveGrants(ctx context.Context, roleId string, version u
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(grantStrings) > 0 {
opts.valueMap["grant_strings"] = grantStrings
}
@@ -462,10 +453,6 @@ func (c *RolesClient) RemoveGrants(ctx context.Context, roleId string, version u
return nil, nil, fmt.Errorf("error creating RemoveGrants request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during RemoveGrants call: %w", err)
@@ -507,6 +494,8 @@ func (c *RolesClient) RemovePrincipals(ctx context.Context, roleId string, versi
version = existingTarget.Version
}
opts.valueMap["version"] = version
if len(principalIds) > 0 {
opts.valueMap["principal_ids"] = principalIds
}
@@ -516,10 +505,6 @@ func (c *RolesClient) RemovePrincipals(ctx context.Context, roleId string, versi
return nil, nil, fmt.Errorf("error creating RemovePrincipals request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during RemovePrincipals call: %w", err)
+2 -4
View File
@@ -120,15 +120,13 @@ func (c *ScopesClient) Update(ctx context.Context, scopeId string, version uint3
version = existingTarget.Version
}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", fmt.Sprintf("scopes/%s", scopeId), opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)
+2 -5
View File
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"net/url"
"time"
"github.com/kr/pretty"
@@ -114,15 +113,13 @@ func (c *UsersClient) Update(ctx context.Context, userId string, version uint32,
version = existingTarget.Version
}
opts.valueMap["version"] = version
req, err := c.client.NewRequest(ctx, "PATCH", fmt.Sprintf("users/%s", userId), opts.valueMap, apiOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating Update request: %w", err)
}
q := url.Values{}
q.Add("version", fmt.Sprintf("%d", version))
req.URL.RawQuery = q.Encode()
resp, err := c.client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Update call: %w", err)