| 15 | _endpoints = {} |
| 16 | |
| 17 | def __init__(self, *, parent=None, con=None, **kwargs): |
| 18 | if parent and con: |
| 19 | raise ValueError('Need a parent or a connection but not both') |
| 20 | self.con = parent.con if parent else con |
| 21 | |
| 22 | # Choose the main_resource passed in kwargs over the parent main_resource |
| 23 | main_resource = kwargs.pop('main_resource', None) or ( |
| 24 | getattr(parent, 'main_resource', None) if parent else None) |
| 25 | |
| 26 | super().__init__(protocol=parent.protocol if parent else kwargs.get('protocol'), main_resource=main_resource) |
| 27 | |
| 28 | cloud_data = kwargs.get(self._cloud_data_key, {}) |
| 29 | |
| 30 | self.object_id = cloud_data.get('id') |
| 31 | self.column_group = cloud_data.get(self._cc('columnGroup'), None) |
| 32 | self.description = cloud_data.get(self._cc('description'), None) |
| 33 | self.display_name = cloud_data.get(self._cc('displayName'), None) |
| 34 | self.enforce_unique_values = cloud_data.get(self._cc('enforceUniqueValues'), None) |
| 35 | self.hidden = cloud_data.get(self._cc('hidden'), None) |
| 36 | self.indexed = cloud_data.get(self._cc('indexed'), None) |
| 37 | self.internal_name = cloud_data.get(self._cc('name'), None) |
| 38 | self.read_only = cloud_data.get(self._cc('readOnly'), None) |
| 39 | self.required = cloud_data.get(self._cc('required'), None) |
| 40 | |
| 41 | # identify the sharepoint column type and set it |
| 42 | # Graph api doesn't return the type for managed metadata and link column |
| 43 | if cloud_data.get(self._cc('text'), None) is not None: |
| 44 | self.field_type = 'text' |
| 45 | elif cloud_data.get(self._cc('choice'), None) is not None: |
| 46 | self.field_type = 'choice' |
| 47 | elif cloud_data.get(self._cc('number'), None) is not None: |
| 48 | self.field_type = 'number' |
| 49 | elif cloud_data.get(self._cc('currency'), None) is not None: |
| 50 | self.field_type = 'currency' |
| 51 | elif cloud_data.get(self._cc('dateTime'), None) is not None: |
| 52 | self.field_type = 'dateTime' |
| 53 | elif cloud_data.get(self._cc('lookup'), None) is not None: |
| 54 | self.field_type = 'lookup' |
| 55 | elif cloud_data.get(self._cc('boolean'), None) is not None: |
| 56 | self.field_type = 'boolean' |
| 57 | elif cloud_data.get(self._cc('calculated'), None) is not None: |
| 58 | self.field_type = 'calculated' |
| 59 | elif cloud_data.get(self._cc('personOrGroup'), None) is not None: |
| 60 | self.field_type = 'personOrGroup' |
| 61 | else: |
| 62 | self.field_type = None |
| 63 | |
| 64 | def __repr__(self): |
| 65 | return 'List Column: {0}-{1}'.format(self.display_name, self.field_type) |