github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/identity/v3.0/users/results.go (about)

     1  package users
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  )
     6  
     7  // User represents a User in the OpenStack Identity Service.
     8  type User struct {
     9  	ID               string `json:"id"`
    10  	DomainID         string `json:"domain_id"`
    11  	Name             string `json:"name"`
    12  	Email            string `json:"email"`
    13  	AreaCode         string `json:"areacode"`
    14  	Phone            string `json:"phone"`
    15  	Description      string `json:"description"`
    16  	AccessMode       string `json:"access_mode"`
    17  	Enabled          bool   `json:"enabled"`
    18  	PasswordStatus   bool   `json:"pwd_status"`
    19  	PasswordStrength string `json:"pwd_strength"`
    20  	CreateAt         string `json:"create_time"`
    21  	UpdateAt         string `json:"update_time"`
    22  	LastLogin        string `json:"last_login_time"`
    23  	XUserID          string `json:"xuser_id"`
    24  	XUserType        string `json:"xuser_type"`
    25  
    26  	// Links contains referencing links to the user.
    27  	Links map[string]interface{} `json:"links"`
    28  }
    29  
    30  type userResult struct {
    31  	golangsdk.Result
    32  }
    33  
    34  // GetResult is the response from a Get operation. Call its Extract method
    35  // to interpret it as a User.
    36  type GetResult struct {
    37  	userResult
    38  }
    39  
    40  // CreateResult is the response from a Create operation. Call its Extract method
    41  // to interpret it as a User.
    42  type CreateResult struct {
    43  	userResult
    44  }
    45  
    46  // UpdateResult is the response from an Update operation. Call its Extract
    47  // method to interpret it as a User.
    48  type UpdateResult struct {
    49  	userResult
    50  }
    51  
    52  // LoginProtect represents a LoginProtect in the OpenStack Identity LoginProtect Service.
    53  type LoginProtect struct {
    54  	Enabled            bool   `json:"enabled"`
    55  	VerificationMethod string `json:"verification_method"`
    56  }
    57  
    58  // UpdateLoginProtectResult is the response from an UpdateLoginProtect operation. Call its
    59  // ExtractLoginProtect method to interpret it as a LoginProtect.
    60  type UpdateLoginProtectResult struct {
    61  	userResult
    62  }
    63  
    64  // GetLoginProtectResult is the response from a GetLoginProtect operation. Call its
    65  // ExtractLoginProtect method to interpret it as a LoginProtect.
    66  type GetLoginProtectResult struct {
    67  	userResult
    68  }
    69  
    70  // Extract interprets any user results as a User.
    71  func (r userResult) Extract() (*User, error) {
    72  	var s struct {
    73  		User *User `json:"user"`
    74  	}
    75  	err := r.ExtractInto(&s)
    76  	return s.User, err
    77  }
    78  
    79  // ExtractLoginProtect interprets any user login protect results as a LoginProtect.
    80  func (r userResult) ExtractLoginProtect() (*LoginProtect, error) {
    81  	var s struct {
    82  		LoginProtect *LoginProtect `json:"login_protect"`
    83  	}
    84  	err := r.ExtractInto(&s)
    85  	return s.LoginProtect, err
    86  }