dangogh commented on a change in pull request #2834: TO Golang: Rewrite
/api/*/users endpoints
URL: https://github.com/apache/trafficcontrol/pull/2834#discussion_r218873676
##########
File path: lib/go-tc/users.go
##########
@@ -19,114 +19,111 @@ package tc
* under the License.
*/
-import (
- "time"
-)
-
-// UsersResponse ...
-type UsersResponse struct {
- Response []User `json:"response"`
+// UserCredentials contains Traffic Ops login credentials
+type UserCredentials struct {
+ Username string `json:"u"`
+ Password string `json:"p"`
}
-// User contains information about a given user in Traffic Ops.
-type User struct {
- Username string `json:"username,omitempty"`
- PublicSSHKey string `json:"publicSshKey,omitempty"`
- Role int `json:"role,omitempty"`
- RoleName string `json:"rolename,omitempty"`
- ID int `json:"id,omitempty"`
- UID int `json:"uid,omitempty"`
- GID int `json:"gid,omitempty"`
- Company string `json:"company,omitempty"`
- Email string `json:"email,omitempty"`
- FullName string `json:"fullName,omitempty"`
- NewUser bool `json:"newUser,omitempty"`
- LastUpdated string `json:"lastUpdated,omitempty"`
+// UserV13 contains non-nullable TO user information
+type UserV13 struct {
+ Username string `json:"username"`
+ PublicSSHKey string `json:"publicSshKey"`
+ Role int `json:"role"`
+ RoleName string `json:"rolename"`
+ ID int `json:"id"`
+ UID int `json:"uid"`
+ GID int `json:"gid"`
+ Company string `json:"company"`
+ Email string `json:"email"`
+ FullName string `json:"fullName"`
+ NewUser bool `json:"newUser"`
+ LastUpdated string `json:"lastUpdated"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
City string `json:"city"`
Country string `json:"country"`
PhoneNumber string `json:"phoneNumber"`
PostalCode string `json:"postalCode"`
- RegistrationSent time.Time `json:"registrationSent"`
+ RegistrationSent TimeNoMod `json:"registrationSent"`
StateOrProvince string `json:"stateOrProvince"`
Tenant string `json:"tenant"`
TenantID int `json:"tenantId"`
}
-// Credentials contains Traffic Ops login credentials
-type UserCredentials struct {
- Username string `json:"u"`
- Password string `json:"p"`
+// commonUserFields is unexported, but its contents are still visible when it
is embedded
+// LastUpdated is a new field for some structs
+type commonUserFields struct {
+ AddressLine1 *string `json:"addressLine1" db:"address_line1"`
+ AddressLine2 *string `json:"addressLine2" db:"address_line2"`
+ City *string `json:"city" db:"city"`
+ Company *string `json:"company" db:"company"`
+ Country *string `json:"country" db:"country"`
+ Email *string `json:"email" db:"email"`
+ FullName *string `json:"fullName" db:"full_name"`
+ GID *int `json:"gid"`
+ ID *int `json:"id" db:"id"`
+ NewUser *bool `json:"newUser" db:"new_user"`
+ PhoneNumber *string `json:"phoneNumber" db:"phone_number"`
+ PostalCode *string `json:"postalCode" db:"postal_code"`
+ PublicSSHKey *string `json:"publicSshKey" db:"public_ssh_key"`
+ Role *int `json:"role" db:"role"`
+ RoleName *string `json:"rolename"`
+ StateOrProvince *string `json:"stateOrProvince" db:"state_or_province"`
+ Tenant *string `json:"tenant"`
+ TenantID *int `json:"tenantId" db:"tenant_id"`
+ UID *int `json:"uid"`
+ //Username *string `json:"username" db:"username"` //not
including major change due to naming incompatibility
+ LastUpdated *TimeNoMod `json:"lastUpdated" db:"last_updated"`
//including minor change to add field
}
-// TODO reconcile APIUser and User
+// User fields in v14 have been updated to be nullable. omitempty is used to
protect password data
+type User struct {
Review comment:
question: how does omitempty protect password data? if it's not empty, it
will be put in the json on a GET.
So don't the passwords need to be in a wrapping struct for POST/PUT so they
can be left out on GET?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services