in source/client/python/api-v0.1/api/connector.py [0:0]
def init(self, agent_config_data, username="", password="", cognitoidp_client=None, s3_custom_resource=None,
redis_custom_connection=None):
"""
Args:
redis_custom_connection(object): override default redis connection
s3_custom_resource(object): override default s3 resource
cognitoidp_client(object): override default s3 cognito client
agent_config_data (dict): the HTC grid runtime configuration for the connector
username (string): the username used for authentication when the client run outside of a VPC
password (string): the password used for authentication when the client run outside of a VPC
Returns:
Nothing
"""
logging.info("AGENT:", agent_config_data)
self.in_out_manager = in_out_manager(
agent_config_data['grid_storage_service'],
agent_config_data['s3_bucket'],
agent_config_data['redis_url'],
s3_region=agent_config_data['region'],
s3_custom_resource=s3_custom_resource,
redis_custom_connection=redis_custom_connection)
self.__api_gateway_endpoint = ""
self.__public_api_gateway_endpoint = agent_config_data['public_api_gateway_url']
self.__private_api_gateway_endpoint = agent_config_data['private_api_gateway_url']
self.__api_key = agent_config_data['api_gateway_key']
self.__user_pool_id = agent_config_data['user_pool_id']
self.__user_pool_client_id = agent_config_data['cognito_userpool_client_id']
self.__username = username
self.__password = password
self.__dynamodb_results_pull_intervall = agent_config_data['dynamodb_results_pull_interval_sec']
self.__task_input_passed_via_external_storage = agent_config_data['task_input_passed_via_external_storage']
self.__user_token_id = None
if cognitoidp_client is None:
self.__cognito_client = boto3.client('cognito-idp', region_name=agent_config_data['region'])
else:
self.__cognito_client = cognitoidp_client
self.__intra_vpc = False
logging.warning("Check Private Mode")
if os.environ.get('INTRA_VPC'):
logging.warning("The client run inside a VPC")
self.__intra_vpc = True
self.__authorization_headers = {}
if self.__intra_vpc:
self.__api_gateway_endpoint = self.__private_api_gateway_endpoint
self.__configuration = Configuration(host=self.__api_gateway_endpoint)
self.__configuration.api_key['api_key'] = self.__api_key
else:
self.__api_gateway_endpoint = self.__public_api_gateway_endpoint
self.__configuration = Configuration(host=self.__api_gateway_endpoint)
self.__scheduler = BackgroundScheduler()
logging.info("LAMBDA_ENDPOINT_URL:{}".format(self.__api_gateway_endpoint))
logging.info("dynamodb_results_pull_interval_sec:{}".format(self.__dynamodb_results_pull_intervall))
logging.info("task_input_passed_via_external_storage:{}".format(self.__task_input_passed_via_external_storage))
logging.info("grid_storage_service:{}".format(agent_config_data['grid_storage_service']))
logging.info("AWSConnector Initialized")
logging.info("init with {}".format(self.__user_pool_client_id))
logging.info("init with {}".format(self.__cognito_client))