@@ -1008,16 +1008,34 @@ descope_client.mgmt.permission.create(
10081008 description = " Optional description to briefly explain what this permission allows."
10091009)
10101010
1011+ # Create a batch of permissions in a single atomic transaction.
1012+ descope_client.mgmt.permission.create_batch(
1013+ permissions = [
1014+ {" name" : " Permission 1" , " description" : " First permission" },
1015+ {" name" : " Permission 2" , " description" : " Second permission" },
1016+ ]
1017+ )
1018+
10111019# Update will override all fields as is. Use carefully.
10121020descope_client.mgmt.permission.update(
10131021 name = " My Permission" ,
10141022 new_name = " My Updated Permission" ,
10151023 description = " A revised description"
10161024)
10171025
1026+ # Update a batch of permissions in a single atomic transaction.
1027+ descope_client.mgmt.permission.update_batch(
1028+ permissions = [
1029+ {" name" : " Permission 1" , " newName" : " Updated Permission 1" , " description" : " Updated description" },
1030+ ]
1031+ )
1032+
10181033# Permission deletion cannot be undone. Use carefully.
10191034descope_client.mgmt.permission.delete(" My Updated Permission" )
10201035
1036+ # Delete a batch of permissions in a single atomic transaction. Cannot be undone. Use carefully.
1037+ descope_client.mgmt.permission.delete_batch([" Permission 1" , " Permission 2" ])
1038+
10211039# Load all permissions
10221040permissions_resp = descope_client.mgmt.permission.load_all()
10231041permissions = permissions_resp[" permissions" ]
@@ -1036,19 +1054,44 @@ descope_client.mgmt.role.create(
10361054 description = " Optional description to briefly explain what this role allows." ,
10371055 permission_names = [" My Updated Permission" ],
10381056 tenant_id = " Optionally scope this role for this specific tenant. If left empty, the role will be available to all tenants." ,
1057+ default = False , # Optional, marks this role as default role
10391058 private = False # Optional, marks this role as private role
10401059)
10411060
1061+ # Create a batch of roles in a single atomic transaction.
1062+ descope_client.mgmt.role.create_batch(
1063+ roles = [
1064+ {" name" : " Role 1" , " description" : " First role" , " permissionNames" : [" Permission 1" ]},
1065+ {" name" : " Role 2" , " description" : " Second role" , " permissionNames" : [" Permission 2" ], " default" : True },
1066+ ]
1067+ )
1068+
10421069# Update will override all fields as is. Use carefully.
10431070descope_client.mgmt.role.update(
10441071 name = " My Role" ,
10451072 new_name = " My Updated Role" ,
10461073 description = " A revised description" ,
10471074 permission_names = [" My Updated Permission" , " Another Permission" ],
10481075 tenant_id = " The tenant ID to which this role is associated, leave empty, if role is a global one" ,
1076+ default = False , # Optional, marks this role as default role
10491077 private = True # Optional, marks this role as private role
10501078)
10511079
1080+ # Update a batch of roles in a single atomic transaction.
1081+ descope_client.mgmt.role.update_batch(
1082+ roles = [
1083+ {" name" : " Role 1" , " newName" : " Updated Role 1" , " description" : " Updated description" , " permissionNames" : [" Permission 1" ]},
1084+ ]
1085+ )
1086+
1087+ # Delete a batch of roles in a single atomic transaction. This action is irreversible. Use carefully.
1088+ descope_client.mgmt.role.delete_batch(
1089+ roles = [
1090+ {" name" : " Role 1" },
1091+ {" name" : " Role 2" , " tenantId" : " <tenant_id>" },
1092+ ]
1093+ )
1094+
10521095# Role deletion cannot be undone. Use carefully.
10531096descope_client.mgmt.role.delete(" My Updated Role" , " <tenant_id>" )
10541097
0 commit comments