Skip to content

Commit

Permalink
initial edits. Needs testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmfwolf committed Jul 31, 2023
1 parent 5a96162 commit 06a4f46
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 42 deletions.
22 changes: 22 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"fmt"

"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin/models"
)

func main() {
UserTwo := models.User{Firstname: "Mikhail", Lastname: "Beaverton", Email: "[email protected]"}
UserQueryOne := models.UserQuery{Email: &UserTwo.Email}

Client, err := onelogin.NewOneloginSDK()
if err != nil {
fmt.Println(err)
}

Client.CreateUser(models.User{Firstname: "Jane", Lastname: "Pukalava", Email: "[email protected]"})
Client.CreateUser(UserTwo)
Client.GetUsers(&UserQueryOne)
}
68 changes: 34 additions & 34 deletions pkg/onelogin/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,40 +46,40 @@ type UserQuery struct {

// User represents a OneLogin User
type User struct {
Firstname *string `json:"firstname,omitempty"`
Lastname *string `json:"lastname,omitempty"`
Username *string `json:"username,omitempty"`
Email *string `json:"email,omitempty"`
DistinguishedName *string `json:"distinguished_name,omitempty"`
Samaccountname *string `json:"samaccountname,omitempty"`
UserPrincipalName *string `json:"userprincipalname,omitempty"`
MemberOf *string `json:"member_of,omitempty"`
Phone *string `json:"phone,omitempty"`
Password *string `json:"password,omitempty"`
PasswordConfirmation *string `json:"password_confirmation,omitempty"`
PasswordAlgorithm *string `json:"password_algorithm,omitempty"`
Salt *string `json:"salt,omitempty"`
Title *string `json:"title,omitempty"`
Company *string `json:"company,omitempty"`
Department *string `json:"department,omitempty"`
Comment *string `json:"comment,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
ActivatedAt *time.Time `json:"activated_at,omitempty"`
LastLogin *time.Time `json:"last_login,omitempty"`
PasswordChangedAt *time.Time `json:"password_changed_at,omitempty"`
LockedUntil *time.Time `json:"locked_until,omitempty"`
InvitationSentAt *time.Time `json:"invitation_sent_at,omitempty"`
State *int32 `json:"state,omitempty"`
Status *int32 `json:"status,omitempty"`
InvalidLoginAttempts *int32 `json:"invalid_login_attempts,omitempty"`
GroupID *int32 `json:"group_id,omitempty"`
DirectoryID *int32 `json:"directory_id,omitempty"`
TrustedIDPID *int32 `json:"trusted_idp_id,omitempty"`
ManagerADID *int32 `json:"manager_ad_id,omitempty"`
ManagerUserID *int32 `json:"manager_user_id,omitempty"`
ExternalID *int32 `json:"external_id,omitempty"`
ID *int32 `json:"id,omitempty"`
Firstname string `json:"firstname,omitempty"`
Lastname string `json:"lastname,omitempty"`
Username string `json:"username,omitempty"`
Email string `json:"email,omitempty"`
DistinguishedName string `json:"distinguished_name,omitempty"`
Samaccountname string `json:"samaccountname,omitempty"`
UserPrincipalName string `json:"userprincipalname,omitempty"`
MemberOf string `json:"member_of,omitempty"`
Phone string `json:"phone,omitempty"`
Password string `json:"password,omitempty"`
PasswordConfirmation string `json:"password_confirmation,omitempty"`
PasswordAlgorithm string `json:"password_algorithm,omitempty"`
Salt string `json:"salt,omitempty"`
Title string `json:"title,omitempty"`
Company string `json:"company,omitempty"`
Department string `json:"department,omitempty"`
Comment string `json:"comment,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
ActivatedAt time.Time `json:"activated_at,omitempty"`
LastLogin time.Time `json:"last_login,omitempty"`
PasswordChangedAt time.Time `json:"password_changed_at,omitempty"`
LockedUntil time.Time `json:"locked_until,omitempty"`
InvitationSentAt time.Time `json:"invitation_sent_at,omitempty"`
State int32 `json:"state,omitempty"`
Status int32 `json:"status,omitempty"`
InvalidLoginAttempts int32 `json:"invalid_login_attempts,omitempty"`
GroupID int32 `json:"group_id,omitempty"`
DirectoryID int32 `json:"directory_id,omitempty"`
TrustedIDPID int32 `json:"trusted_idp_id,omitempty"`
ManagerADID int32 `json:"manager_ad_id,omitempty"`
ManagerUserID int32 `json:"manager_user_id,omitempty"`
ExternalID int32 `json:"external_id,omitempty"`
ID int32 `json:"id,omitempty"`
CustomAttributes map[string]interface{} `json:"custom_attributes,omitempty"`
}

Expand Down
40 changes: 32 additions & 8 deletions pkg/onelogin/models/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,48 @@ type Queryable interface {

// validateString checks if the provided value is a string.
func validateString(val interface{}) bool {
_, ok := val.(string)
return ok
switch v := val.(type) {
case string:
return true
case *string:
return v != nil
default:
return false
}
}

// validateTime checks if the provided value is a time.Time.
func validateTime(val interface{}) bool {
_, ok := val.(*time.Time)
return ok
switch v := val.(type) {
case time.Time:
return true
case *time.Time:
return v != nil
default:
return false
}
}

// validateInt checks if the provided value is an int.
func validateInt(val interface{}) bool {
_, ok := val.(int)
return ok
switch v := val.(type) {
case int:
return true
case *int:
return v != nil
default:
return false
}
}

// validateBool checks if the provided value is a bool.
func validateBool(val interface{}) bool {
_, ok := val.(bool)
return ok
switch v := val.(type) {
case bool:
return true
case *bool:
return v != nil
default:
return false
}
}

0 comments on commit 06a4f46

Please sign in to comment.