dfcx-scrapi icon indicating copy to clipboard operation
dfcx-scrapi copied to clipboard

[BUG] update_webhook doesn't work properly when you pass a webhook_obj

Open MRyderOC opened this issue 1 year ago • 2 comments

Expected Behavior

Update the webhook in the target agent.

Current Behavior

Does not perform any action.

Possible Solution

based on https://github.com/googleapis/python-dialogflow-cx/blob/f2d12c53804dec7b236509aa29b200aebcc53c8a/google/cloud/dialogflowcx_v3beta1/types/webhook.py#L305-L308

we have to update the mask only if the kwargs pass to the function and not when we pass the webhook_obj.

Steps to Reproduce

  1. Create a webhook in the agent.
  2. Pull the webhook using list_webhooks method in dfcx_scrapi.core.webhoks.Webhooks
  3. Change an attribute of the webhook e.g. timeout
from datetime import timedelta
my_webhook.timeout = timedelta(seconds=12)
  1. Update the webhook
webhook_instance.update_webhook(
    webhook_id=my_webhook.name,
    webhook_obj=my_webhook
)

Possible Implementation

mask = None
if kwargs:
    ... # existing code
    mask = field_mask_pb2.FieldMask(paths=paths)
... # existing code
if mask:
    request.update_mask = mask
... # existing code 

MRyderOC avatar Feb 21 '23 19:02 MRyderOC