/
main.go
38 lines (28 loc) · 1.07 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"os"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin/models"
)
func main() {
// Set environment variables for OneLogin API credentials
os.Setenv("ONELOGIN_CLIENT_ID", "client_id")
os.Setenv("ONELOGIN_CLIENT_SECRET", "client_secret")
os.Setenv("ONELOGIN_SUBDOMAIN", "your-api-subdomain")
// Create a user object with the specified attributes
UserTwo := models.User{Firstname: "Mikhail", Lastname: "Beaverton", Email: "mb@example.com"}
// Create a user query object with the specified email
UserQueryOne := models.UserQuery{Email: &UserTwo.Email}
// Create a new OneLogin SDK client
Client, err := onelogin.NewOneloginSDK()
if err != nil {
fmt.Println(err)
}
// Create a new user with the specified attributes
Client.CreateUser(models.User{Firstname: "Jane", Lastname: "Pukalava", Email: "jp@example.com"})
// Create a new user with the specified attributes
Client.CreateUser(UserTwo)
// Get a list of users that match the specified query
Client.GetUsers(&UserQueryOne)
}