From 69fe429e308797e534bd7fe2e34482a60dcee1df Mon Sep 17 00:00:00 2001 From: skysharma Date: Sun, 23 Jul 2023 19:31:51 -0500 Subject: [PATCH] Implementing, using new FieldMask class --- clearblade/cloud/iot_v1/device_types.py | 4 ++-- clearblade/cloud/iot_v1/resources.py | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/clearblade/cloud/iot_v1/device_types.py b/clearblade/cloud/iot_v1/device_types.py index a63d3524..cc7dabf2 100644 --- a/clearblade/cloud/iot_v1/device_types.py +++ b/clearblade/cloud/iot_v1/device_types.py @@ -43,7 +43,7 @@ """ from typing import List -from .resources import GatewayType, LogLevel, PublicKeyFormat, PublicKeyCredential, DeviceCredential +from .resources import GatewayType, LogLevel, PublicKeyFormat, PublicKeyCredential, DeviceCredential, FieldMask from .utils import get_value import os from proto.datetime_helpers import DatetimeWithNanoseconds @@ -589,7 +589,7 @@ def _prepare_params_for_list(self): if self.device_ids: params['deviceIds'] = self.device_ids if self.field_mask: - params['fieldMask'] = self.field_mask + params['fieldMask'] = FieldMask.convert_fieldmask_for_list(self.field_mask) if self.gateway_list_options : if 'associationsDeviceId' in self.gateway_list_options: params['gatewayListOptions.associationsDeviceId'] = self.gateway_list_options['associationsDeviceId'] diff --git a/clearblade/cloud/iot_v1/resources.py b/clearblade/cloud/iot_v1/resources.py index b933a701..0d37e590 100644 --- a/clearblade/cloud/iot_v1/resources.py +++ b/clearblade/cloud/iot_v1/resources.py @@ -168,4 +168,22 @@ def convert_credentials_for_create_update(cls, credentials): if updateDeviceCredential: credentials[index] = credential - return credentials \ No newline at end of file + return credentials + +class FieldMask(): + def __init__(self, paths: [str]): + self.paths = paths + + def __getitem__(self, arg): + return getattr(self, arg) + + def get(self, arg): + return getattr(self, arg) + + @classmethod + def convert_fieldmask_for_list(cls, field_mask): + if (isinstance(field_mask, FieldMask)): + field_mask = field_mask.__dict__ + if 'paths' in field_mask: + field_mask = field_mask['paths'] + return field_mask