Skip to content
Snippets Groups Projects
Commit 1d682e3d authored by Jedrzej Rybicki's avatar Jedrzej Rybicki
Browse files

cons

parent 8c1f4376
Branches
Tags
No related merge requests found
Pipeline #76832 passed
...@@ -20,5 +20,6 @@ test: ...@@ -20,5 +20,6 @@ test:
- pwd - pwd
- cp dags/* /opt/airflow/dags/ - cp dags/* /opt/airflow/dags/
- airflow dags list - airflow dags list
- airflow connections list
- airflow dags test firsto 2021-08-18 - airflow dags test firsto 2021-08-18
from airflow.models.baseoperator import BaseOperator from airflow.models.baseoperator import BaseOperator
from airflow.models.connection import Connection from airflow.models.connection import Connection
import requests import requests
from urllib.parse import urljoin
def get_objects(server): def get_objects(server):
lst = requests.get(urljoin(server, 'api/records')).json() lst = requests.get(urljoin(server, 'api/records')).json()
return lst['hits']['hits'] return lst['hits']['hits']
server='https://b2share-testing.fz-juelich.de/'
class B2ShareOperator(BaseOperator): class B2ShareOperator(BaseOperator):
...@@ -16,15 +18,15 @@ class B2ShareOperator(BaseOperator): ...@@ -16,15 +18,15 @@ class B2ShareOperator(BaseOperator):
**kwargs) -> None: **kwargs) -> None:
super().__init__(**kwargs) super().__init__(**kwargs)
self.name = name self.name = name
self.connection = Connection.get_connection_from_secrets(conn_id) #self.connection = Connection.get_connection_from_secrets(conn_id)
def execute(self, context): def execute(self, context):
message = "Hello {}".format(self.name) message = "Hello {}".format(self.name)
print(message) print(message)
print(self.connection.host) #print(self.connection.host)
print(f"Retrieving info from {self.connection.host}") #print(f"Retrieving info from {self.connection.host}")
lst = get_objects(server=self.connection.schema+self.connection.host) lst = get_objects(server=server)
print(f"GOT: {lst}") print(f"GOT: {lst}")
return message return message
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment