onelogin / onelogin-go-sdk

golang sdk for onelogin apis
MIT License
10 stars 24 forks source link

DEVEX-1619 Fix adding admins and users for roles api call #85

Closed nilayanand closed 1 week ago

nilayanand commented 1 week ago

DEVEX-1619 Fix adding admins and users for roles api call

Test using following Golang code

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() {

      os.Setenv("ONELOGIN_CLIENT_ID", "client_id")
      os.Setenv("ONELOGIN_CLIENT_SECRET", "client secret")
      os.Setenv("ONELOGIN_SUBDOMAIN", "subdomain")
      os.Setenv("ONELOGIN_TIMEOUT", "15")

      ol, err := onelogin.NewOneloginSDK()
      if err != nil {
            fmt.Println("Unable to initialize client:", err)
            return
      }

      users := []int{1234}                // replace 1234 with actual user id
      apiResp, err := ol.AddRoleUsers(4321, users)          // replace 4321 with actual role id
      if err != nil {
            fmt.Println("Failed to add users to role:", err)
            return
      }
      fmt.Println("Response:", apiResp)
}