Legacy Dev Forum Posts

 View Only

Sign Up

Genesys api vs terraform export

  • 1.  Genesys api vs terraform export

    Posted 06-05-2025 18:29

    barakaldes | 2023-11-28 15:25:24 UTC | #1

    I need to obtain the roles of all users in my company. To do this, I use the following API: /api/v2/users/{userId}/roles

    The problem is that I have 5000 users, so I have to make this call 5000 times and I receive error messages with code 429 (too many requests).

    My question is... why can I obtain the data without any issues using Terraform exports? I mean... if I apply the following:

    resource "genesyscloud_tf_export" "userroles" { 
      directory               = "./userroles" 
      include_filter_resources = ["genesyscloud_user_roles"] 
      export_as_hcl           = true 
      include_state_file      = true
    }

    I quickly retrieve all the information... Which API is Terraform export using to fetch everything at once?


    tim.smith | 2023-11-28 15:31:43 UTC | #2

    Terraform is built to do what you need to do also, which is gracefully handle rate limits.


    barakaldes | 2023-11-28 15:37:14 UTC | #3

    but then the terraform module also uses the same api? (/api/v2/users/{userId}/roles) When I iterate through all users in my company from my Python process, it takes 30 minutes. However, the Terraform module does the same in 1 minute. Does that make sense?


    tim.smith | 2023-11-28 15:41:51 UTC | #4

    You can see which resources are used by a terraform resource in the docs for it: https://github.com/MyPureCloud/terraform-provider-genesyscloud/blob/main/docs/resources/user_roles.md?plain=1#L14-L20. You can also view the source for a resource if you want to know exactly what it's doing: https://github.com/MyPureCloud/terraform-provider-genesyscloud/blob/main/genesyscloud/resource_genesyscloud_user_roles.go.


    minmin68 | 2023-11-29 02:29:42 UTC | #5

    I am not sure about Terraform, but the original UI uses the following API to list user roles:

    /api/v2/users/search

    This API will provide results as shown below.

    "authorization": { "roles": [ { "id": "16e68ee8-1a4b-492b-a269-b6f0ce400d96", "name": "SupervisorUltra" }, { "id": "227d3d82-7e51-43c3-bdb0-14ae22560bf6", "name": "Agent" }, { "id": "51ce9839-f52f-4bfc-ad9a-9d8e039e7547", "name": "ArchitectViewEdit" }, { "id": "fb92e9ca-9d94-46c0-a4d4-ba02900d7dc2", "name": "Supervisor" } ],


    system | 2023-12-29 02:30:36 UTC | #6

    This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 23388