@@ -201,19 +201,25 @@ def delete_user(self, user_id):
201
201
token = workos .api_key ,
202
202
)
203
203
204
- def create_organization_membership (self , user_id , organization_id ):
204
+ def create_organization_membership (self , user_id , organization_id , role_slug = None ):
205
205
"""Create a new OrganizationMembership for the given Organization and User.
206
206
207
207
Args:
208
208
user_id: The Unique ID of the User.
209
209
organization_id: The Unique ID of the Organization to which the user belongs to.
210
+ role_slug: The Unique Slug of the Role to which to grant to this membership.
211
+ If no slug is passed in, the default role will be granted.(Optional)
210
212
211
213
Returns:
212
214
dict: Created OrganizationMembership response from WorkOS.
213
215
"""
214
216
headers = {}
215
217
216
- params = {"user_id" : user_id , "organization_id" : organization_id }
218
+ params = {
219
+ "user_id" : user_id ,
220
+ "organization_id" : organization_id ,
221
+ "role_slug" : role_slug ,
222
+ }
217
223
218
224
response = self .request_helper .request (
219
225
ORGANIZATION_MEMBERSHIP_PATH ,
@@ -225,6 +231,35 @@ def create_organization_membership(self, user_id, organization_id):
225
231
226
232
return WorkOSOrganizationMembership .construct_from_response (response ).to_dict ()
227
233
234
+ def update_organization_membership (
235
+ self , organization_membership_id , role_slug = None
236
+ ):
237
+ """Updates an OrganizationMembership for the given id.
238
+
239
+ Args:
240
+ organization_membership_id (str) - The unique ID of the Organization Membership.
241
+ role_slug: The Unique Slug of the Role to which to grant to this membership.
242
+ If no slug is passed in, it will not be changed (Optional)
243
+
244
+ Returns:
245
+ dict: Created OrganizationMembership response from WorkOS.
246
+ """
247
+ headers = {}
248
+
249
+ params = {
250
+ "role_slug" : role_slug ,
251
+ }
252
+
253
+ response = self .request_helper .request (
254
+ ORGANIZATION_MEMBERSHIP_DETAIL_PATH .format (organization_membership_id ),
255
+ method = REQUEST_METHOD_PUT ,
256
+ params = params ,
257
+ headers = headers ,
258
+ token = workos .api_key ,
259
+ )
260
+
261
+ return WorkOSOrganizationMembership .construct_from_response (response ).to_dict ()
262
+
228
263
def get_organization_membership (self , organization_membership_id ):
229
264
"""Get the details of an organization membership.
230
265
0 commit comments