def get_variable(self, variable_id: str) -> Variable:
     info_var = typhoon_airflow_variable_name_for_info(variable_id)
     value_var = typhoon_airflow_variable_name_for_value(variable_id)
     with set_airflow_db(self.db_path, self.fernet_key) as db:
         info = db.get_variable(info_var)
         if info is None:
             raise MetadataObjectNotFound(f'Variable "{variable_id}" is not set')
         info = json.loads(info)
         value = db.get_variable(value_var)
     return Variable(id=info['id'], type=VariableType(info['type']), contents=value)
 def get_connection(self, conn_id: str) -> Connection:
     try:
         item = dynamodb_helper.dynamodb_get_item(
             ddb_client=self.client,
             table_name=Settings.connections_table_name,
             key_name='conn_id',
             key_value=conn_id,
         )
     except TyphoonResourceNotFoundError:
         raise MetadataObjectNotFound(f'Connection "{conn_id}" is not set')
     return Connection(**item)
 def get_dag_deployment(self, deployment_hash: str) -> DagDeployment:
     try:
         item = dynamodb_helper.dynamodb_query_item(
             ddb_resource=self.resource,
             table_name=Settings.dag_deployments_table_name,
             partition_key_name='deployment_hash',
             partition_key_value=deployment_hash,
         )
     except TyphoonResourceNotFoundError:
         raise MetadataObjectNotFound(
             f'Deployment "{deployment_hash}" is not set')
     return DagDeployment.parse_obj(item)
 def get_variable(self, variable_id: str) -> Variable:
     try:
         item = dynamodb_helper.dynamodb_get_item(
             ddb_client=self.client,
             table_name=Settings.variables_table_name,
             key_name='id',
             key_value=variable_id,
         )
     except TyphoonResourceNotFoundError:
         raise MetadataObjectNotFound(
             f'Variable "{variable_id}" is not set')
     return Variable(**item)
 def get_variables(self, to_dict: bool = False) -> List[Union[dict, Variable]]:
     result = []
     with set_airflow_db(self.db_path, self.fernet_key) as db:
         for af_var in db.get_variables():
             if af_var.key.startswith('typhoon:info#'):
                 info = json.loads(af_var.val)
                 var_id = info['id']
                 value_var = typhoon_airflow_variable_name_for_value(var_id)
                 contents = db.get_variable(value_var)
                 if contents is None:
                     raise MetadataObjectNotFound(f'Variable "{var_id}" does not have a value set')
                 var = Variable(id=var_id, type=VariableType(info['type']), contents=contents)
                 if to_dict:
                     var = var.dict_contents()
                 result.append(var)
     return result
 def get_connection(self, conn_id: str) -> Connection:
     af_name = typhoon_airflow_conn_name(conn_id)
     with set_airflow_db(self.db_path, self.fernet_key) as db:
         af_conn = db.get_connection(af_name)
         if af_conn is None:
             raise MetadataObjectNotFound(f'Connection "{conn_id}" is not set')
         conn = Connection(
             conn_id=conn_id,
             conn_type=af_conn.conn_type,
             host=af_conn.host,
             port=af_conn.port,
             login=af_conn.login,
             password=af_conn.password,
             schema=af_conn.schema,
             extra=af_conn.extra_dejson,
         )
     return conn
 def get_dag_deployment(self, deployment_hash: str) -> DagDeployment:
     if deployment_hash not in self.conn_connections.keys():
         raise MetadataObjectNotFound(
             f'Dag deployment "{deployment_hash}" is not set')
     return self.conn_connections[deployment_hash]
 def get_variable(self, variable_id: str) -> Variable:
     if variable_id not in self.conn_variables.keys():
         raise MetadataObjectNotFound(
             f'Variable "{variable_id}" is not set')
     return self.conn_variables[variable_id]
 def get_connection(self, conn_id: str) -> Connection:
     if conn_id not in self.conn_connections.keys():
         raise MetadataObjectNotFound(f'Connection "{conn_id}" is not set')
     return self.conn_connections[conn_id]