(self, params, node=None, **kwargs)
| 129 | return scim_create_parser |
| 130 | |
| 131 | def execute(self, params, node=None, **kwargs): |
| 132 | if not node: |
| 133 | logging.warning('\"--node\" option is required for \"create\" command') |
| 134 | return |
| 135 | nodes = list(self.resolve_nodes(params, node)) |
| 136 | if len(nodes) > 1: |
| 137 | logging.warning('Node name \'%s\' is not unique. Use Node ID.', node) |
| 138 | return |
| 139 | elif len(nodes) == 0: |
| 140 | logging.warning('Node name \'%s\' is not found', node) |
| 141 | return |
| 142 | |
| 143 | matched_node = nodes[0] |
| 144 | if not matched_node.get('parent_id'): |
| 145 | logging.warning('Root node cannot be used for SCIM endpoint') |
| 146 | return |
| 147 | token = base64.urlsafe_b64encode(os.urandom(32)).decode().rstrip('=') |
| 148 | rq = { |
| 149 | 'command': 'scim_add', |
| 150 | 'scim_id': self.get_enterprise_id(params), |
| 151 | 'node_id': matched_node['node_id'], |
| 152 | 'token': token, |
| 153 | } |
| 154 | prefix = kwargs.get('prefix') |
| 155 | if prefix: |
| 156 | rq['prefix'] = prefix |
| 157 | if kwargs.get('unique_groups', '') == 'on': |
| 158 | rq['unique_groups'] = True |
| 159 | |
| 160 | api.communicate(params, rq) |
| 161 | api.query_enterprise(params) |
| 162 | scim_url = get_scim_url(params, matched_node['node_id']) |
| 163 | node_id = matched_node['node_id'] |
| 164 | logging.info('') |
| 165 | logging.info('SCIM ID: %d', rq['scim_id']) |
| 166 | logging.info('SCIM URL: %s', scim_url) |
| 167 | logging.info('Provisioning Token: %s', token) |
| 168 | logging.info('') |
| 169 | return { |
| 170 | 'scim_id': rq['scim_id'], |
| 171 | 'scim_url': scim_url, |
| 172 | 'provisioning_token': token, |
| 173 | 'node_name': self.get_node_path(params, node_id), |
| 174 | 'node_id': node_id, |
| 175 | 'prefix': prefix or '', |
| 176 | 'unique_groups': kwargs.get('unique_groups', '') == 'on', |
| 177 | } |
| 178 | |
| 179 | |
| 180 | def find_scim(param, name): # type: (KeeperParams, any) -> dict |
nothing calls this directly
no test coverage detected