github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/identity/v3.0/security/UpdateLoginProtectionConfiguration.go (about)

     1  package security
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  type LoginProtectionUpdateOpts struct {
    10  	// Indicates whether login protection has been enabled for the user. The value can be true or false.
    11  	Enabled *bool `json:"enabled" required:"true"`
    12  	// Login authentication method of the user. Options: sms, email, and vmfa.
    13  	VerificationMethod string `json:"verification_method" required:"true"`
    14  }
    15  
    16  func UpdateLoginProtectionConfiguration(client *golangsdk.ServiceClient, id string, opts LoginProtectionUpdateOpts) (*LoginProtectionConfig, error) {
    17  	b, err := build.RequestBody(opts, "login_protect")
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  
    22  	// PUT /v3.0/OS-USER/users/{user_id}/login-protect
    23  	raw, err := client.Put(client.ServiceURL("OS-USER", "users", id, "login-protect"), b, nil, &golangsdk.RequestOpts{
    24  		OkCodes: []int{200},
    25  	})
    26  	if err != nil {
    27  		return nil, err
    28  	}
    29  
    30  	var res LoginProtectionConfig
    31  	return &res, extract.IntoStructPtr(raw.Body, &res, "login_protect")
    32  }