cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2034
Views
1
Helpful
2
Replies

Using wxc_sdk - create or update workspace, supplying parameters

SPatel19
Level 1
Level 1

Hello Devnet,

I am new to using Webex APIs and  Python. I have followed "Agile Management of Webex Calling - There's an API for that – BRKCOL-3015 " and managed to setup Pycharm and load the wxc_sdk api's. I have successfully connected to my organisation using a service app. I have used and modified the service_app.py example script and can read a workspace setting. My problem comes when trying to create or update a workspace - i cannot seem to write the correct python code to parse the settings parameters when calling the update workspace API.
I used the list workspace api  to obtain the  workspace settings  and was going  modify the capacity  parameter  to 1 and them back using the update api.

workspaceid = "Y2lzY29zcG.....MA=="
wspacedetail = list(api.workspaces.details(workspace_id=workspaceid))
print(f'{len(wspacedetail)} wspacedetail')

Using the above script works fine - I used the output and  tried passing the modified capacity parameter as below

newsettings = \
{
"org_id:": "<omitted>",
"location_id": "<omitted>",
"floor_id": "<omitted>",
"display_name": "London AV Test",
"capacity": 1,
"workspace_type": "meetingRoom",
"sip_address": "london_av_test@l<redacted>.rooms.webex.com",
"created": "2024-03-22T11:28:55.771Z",
"calling": {"type": "hybrid_Calling",
"hybrid_Calling": {"emailAddress": "london-s3.dx80test@<redacted>.com"}},
"calendar": {"type": "microsoft", "emailAddress": "london_s3dx80test@<redacted>.com"},
"hotdesking_Status": "off",
# "deviceHostedMeetings": {"enabled": false },
"supported_Devices": "collaborationDevices",
"device_Platform": "cisco"
}

wsupdate=api.workspaces.update(workspace_id=workspaceid, settings=newsettings)

====

However when running the script, i get an error returned

WARNING:wxc_sdk.base:auto enhancing Enum CallingType, new value: hybridCalling
Traceback (most recent call last):
File "C:\Users\<redacted>\PycharmProjects\WxC-pythonProject\.venv\wxcupdate_app.py", line 196, in <module>
wxcupdate_app()
File "C:\Users\<redacted>\PycharmProjects\WxC-pythonProject\.venv\wxcupdate_app.py", line 184, in wxcupdate_app
wsupdate=api.workspaces.update(workspace_id=workspaceid, settings=newsettings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\<redacted>\PycharmProjects\WxC-pythonProject\.venv\Lib\site-packages\wxc_sdk\workspaces\__init__.py", line 413, in update
j_data = settings.update_or_create(for_update=True)
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'update_or_create'

I have tried digging down deeper into the class object, but cannot determine how to write the correct python code  to pass the workspace settings when calling the update api. 
I cannot find any other example scripts to follow either.
Can anyone help and let me know how the code should be written or point me in the write direction?

thxs

Sanjay

1 Accepted Solution

Hi Rudrakshi,

The wxc_sdk was created by Johannes Krohn, Principal Technical Marketing Engineer, Cisco and is publically available at  wxc_sdk — wxc_sdk 1.19.0 documentation (wxc-sdk.readthedocs.io). It was just what I was looking for as it allows me to use APIs to perform scripted changes to many workspaces globally. 

The error I got was down to a lack of  knowledge of python and coding. I managed to get the update API working by following the code in another example script found in the sdk.

After changing my code to below, the workspace updated ok.

from wxc_sdk.workspaces import Workspace, WorkspaceSupportedDevices, CallingType, WorkspaceCalling
workspaceid = "abc123xyz789"
update = Workspace()
update.capacity = 4
api.workspaces.update(workspace_id=workspaceid, settings=update)

[I managed to get the Integration and OAuth access token working just fine following the guidelines in the wxc_sdk].

Unfortunately I came across another issue to with updating workspaces that are configured with hybrid calling which i will post separately.

Many thxs

.. Sanjay

 

View solution in original post

2 Replies 2

Rudrakshi
Cisco Employee
Cisco Employee

Hi Sanjay,

It seems you're using some third party python SDK which I'm not aware of and our team also doesn't support it. The error "AttributeError: 'dict' object has no attribute 'update_or_create'" is very specific to the library that you're using.

I would suggest you go through our documentation here: https://developer.webex.com/docs to build understanding around the APIs and test these using postman. You can get the personal access token here: https://developer.webex.com/docs/getting-started, which is a temporary token and would only be valid till 12 Hours max or until the user is logged in (whichever is less).

In order to automate the workflow of calling APIs for an app, it is recommended to use Integration and generate OAuth access token instead of personal access token. The validity for OAuth access token is 14 days and you can use refresh token to generate new access token programmatically. You can read more about Integrations here: https://developer.webex.com/docs/integrations and also review this article: https://developer.webex.com/blog/real-world-walkthrough-of-building-an-oauth-webex-integration, which has demonstrated how to work with integrations using Python sample code.

Hope this helps!



Best regards,
Rudrakshi Srivastava

Hi Rudrakshi,

The wxc_sdk was created by Johannes Krohn, Principal Technical Marketing Engineer, Cisco and is publically available at  wxc_sdk — wxc_sdk 1.19.0 documentation (wxc-sdk.readthedocs.io). It was just what I was looking for as it allows me to use APIs to perform scripted changes to many workspaces globally. 

The error I got was down to a lack of  knowledge of python and coding. I managed to get the update API working by following the code in another example script found in the sdk.

After changing my code to below, the workspace updated ok.

from wxc_sdk.workspaces import Workspace, WorkspaceSupportedDevices, CallingType, WorkspaceCalling
workspaceid = "abc123xyz789"
update = Workspace()
update.capacity = 4
api.workspaces.update(workspace_id=workspaceid, settings=update)

[I managed to get the Integration and OAuth access token working just fine following the guidelines in the wxc_sdk].

Unfortunately I came across another issue to with updating workspaces that are configured with hybrid calling which i will post separately.

Many thxs

.. Sanjay