Pass disable_discovered_config_validation in the API change-state call (#1100)

This commit is contained in:
Todd Knight authored and GitHub committed 2021-04-12 08:49:22 -07:00
1 parent 3130bd615e
commit 71673ea161
9 files changed
+237 -196

No files matched your search

+13 -3
View File
@@ -8,6 +8,12 @@ import (
"github.com/hashicorp/boundary/api"
)
const (
versionPostBodyKey = "version"
attributesPostBodyKey = "attributes"
statePostBodyKey = "state"
)
func (c *Client) ChangeState(ctx context.Context, authMethodId string, version uint32, state string, opt ...Option) (*AuthMethodUpdateResult, error) {
if authMethodId == "" {
return nil, fmt.Errorf("empty authMethodId value passed into ChangeState request")
@@ -38,10 +44,14 @@ func (c *Client) ChangeState(ctx context.Context, authMethodId string, version u
version = existingTarget.Item.Version
}
reqBody := map[string]interface{}{
"version": version,
"attributes": map[string]interface{}{"state": state},
reqBody := opts.postMap
reqBody[versionPostBodyKey] = version
attrMap, ok := reqBody[attributesPostBodyKey].(map[string]interface{})
if !ok {
attrMap = make(map[string]interface{})
reqBody[attributesPostBodyKey] = attrMap
}
attrMap[statePostBodyKey] = state
req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("auth-methods/%s:change-state", authMethodId), reqBody, apiOpts...)
if err != nil {