MCPcopy Index your code
hub / github.com/diffgram/diffgram / get_custom_url_supported_connector

Function get_custom_url_supported_connector

shared/url_generation.py:165–198  ·  view source on GitHub ↗

Gets the connector object and checks if it supports custom signed urls with a custom service. :param session: :param log: :param connection_id: :param connection: :return:

(session: Session, log: dict, connection_id: int)

Source from the content-addressed store, hash-verified

163
164
165def get_custom_url_supported_connector(session: Session, log: dict, connection_id: int) -> [object, dict]:
166 """
167 Gets the connector object and checks if it supports custom signed urls with a custom service.
168 :param session:
169 :param log:
170 :param connection_id:
171 :param connection:
172 :return:
173 """
174 connection = Connection.get_by_id(session = session, id = connection_id)
175 if connection is None:
176 msg = f'connection id: {connection_id} not found.'
177 log['error']['connection_id'] = msg
178 logger.error(msg)
179 return None, log
180 if connection.integration_name not in ALLOWED_CONNECTION_SIGNED_URL_PROVIDERS:
181 msg = f'Unsupported connection provider for URL regeneration {connection.id}:{connection.integration_name}'
182 log['error']['unsupported'] = msg
183 log['error']['supported_providers'] = ALLOWED_CONNECTION_SIGNED_URL_PROVIDERS
184 logger.error(msg)
185 return None, log
186
187 connection_strategy = ConnectionStrategy(
188 connection_id = connection_id,
189 session = session)
190
191 client, success = connection_strategy.get_connector(connection_id = connection_id)
192 if not success:
193 msg = f'Failed to get connector for connection {connection_id}'
194 log['error']['connector'] = msg
195 logger.error(msg)
196 return None, log
197
198 return client, log
199
200
201

Calls 3

get_connectorMethod · 0.95
ConnectionStrategyClass · 0.90
get_by_idMethod · 0.45

Tested by

no test coverage detected