| 193 | return import_parser |
| 194 | |
| 195 | def execute(self, params, **kwargs): |
| 196 | if params.enforcements and 'booleans' in params.enforcements: |
| 197 | restricted = next((x['value'] for x in params.enforcements['booleans'] if x['key'] == 'restrict_import'), False) |
| 198 | if restricted: |
| 199 | logging.warning('"import" is restricted by Keeper Administrator') |
| 200 | return |
| 201 | import_format = kwargs['format'] if 'format' in kwargs else None |
| 202 | import_name = kwargs['name'] if 'name' in kwargs else None |
| 203 | if not import_format: |
| 204 | logging.error('"--format" parameter is mandatory') |
| 205 | return |
| 206 | if not import_name: |
| 207 | logging.error('"name" parameter is mandatory') |
| 208 | return |
| 209 | |
| 210 | manage_users = False |
| 211 | manage_records = False |
| 212 | can_edit = False |
| 213 | can_share = False |
| 214 | permissions = '' |
| 215 | if 'permissions' in kwargs: |
| 216 | permissions = kwargs.get('permissions') or '' |
| 217 | del kwargs['permissions'] |
| 218 | |
| 219 | if kwargs.get('shared') is True and not permissions: |
| 220 | permissions = user_choice('Default shared folder permissions: manage (U)sers, manage (R)ecords, can (E)dit, can (S)hare, or (A)ll, (N)one', 'uresan', show_choice=False, multi_choice=True) |
| 221 | if permissions: |
| 222 | chars = set() |
| 223 | chars.update([x for x in permissions.lower()]) |
| 224 | if 'a' in chars: |
| 225 | manage_users = True |
| 226 | manage_records = True |
| 227 | can_edit = True |
| 228 | can_share = True |
| 229 | else: |
| 230 | if 'u' in chars: |
| 231 | manage_users = True |
| 232 | if 'r' in chars: |
| 233 | manage_records = True |
| 234 | if 'e' in chars: |
| 235 | can_edit = True |
| 236 | if 's' in chars: |
| 237 | can_share = True |
| 238 | |
| 239 | if 'login_type' in kwargs: |
| 240 | if kwargs['login_type'] is True: |
| 241 | if 'record_type' in kwargs and kwargs['record_type']: |
| 242 | logging.warning('Options login-type and record-type are mutually exclusive.') |
| 243 | return |
| 244 | kwargs['record_type'] = 'login' |
| 245 | del kwargs['login_type'] |
| 246 | |
| 247 | record_type = kwargs.get('record_type') or '' |
| 248 | if record_type: |
| 249 | rti = None |
| 250 | if params.record_type_cache: |
| 251 | for rts in params.record_type_cache.values(): |
| 252 | try: |