diff --git a/client/robot_account.go b/client/robot_account.go index 0467fca..3f2007a 100755 --- a/client/robot_account.go +++ b/client/robot_account.go @@ -14,6 +14,10 @@ func RobotBody(d *schema.ResourceData) models.RobotBody { Level: d.Get("level").(string), } + if d.Get("secret").(string) != "" { + body.Secret = d.Get("secret").(string) + } + permissions := d.Get("permissions").(*schema.Set).List() for _, p := range permissions { diff --git a/provider/resource_robot_account.go b/provider/resource_robot_account.go index 2305896..fcf4c64 100755 --- a/provider/resource_robot_account.go +++ b/provider/resource_robot_account.go @@ -131,16 +131,7 @@ func resourceRobotAccountCreate(d *schema.ResourceData, m interface{}) error { return err } - if d.Get("secret").(string) != "" { - robotID := strconv.Itoa(jsonData.ID) - secret := models.RobotSecret{ - Secret: d.Get("secret").(string), - } - _, _, _, err := apiClient.SendRequest("PATCH", models.PathRobots+"/"+robotID, secret, 200) - if err != nil { - return err - } - } else { + if d.Get("secret").(string) == "" { d.Set("secret", jsonData.Secret) } @@ -259,16 +250,6 @@ func resourceRobotAccountUpdate(d *schema.ResourceData, m interface{}) error { return err } - if d.HasChange("secret") { - secret := models.RobotSecret{ - Secret: d.Get("secret").(string), - } - _, _, _, err := apiClient.SendRequest("PATCH", d.Id(), secret, 200) - if err != nil { - return err - } - } - return resourceRobotAccountRead(d, m) }