Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
doble quote fix
  • Loading branch information
YannickPassa committed Jan 15, 2025
1 parent 1890a2c commit acf2bee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 7 additions & 0 deletions deployment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,10 @@ variable "fredo_api_token" {
sensitive = true
default = ""
}

variable "imilo_api_secret" {
description = "Used in extraction tasks orchestrated by airflow"
type = string
sensitive = true
default = ""
}
3 changes: 3 additions & 0 deletions pipeline/dags/dag_utils/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,17 @@
"offres": {
"filename": "offres.json",
"url": Variable.get("IMILO_API_URL", None),
"token": Variable.get("IMILO_API_SECRET", None),
},
"structures": {
"filename": "structures.json",
"url": Variable.get("IMILO_API_URL", None),
"token": Variable.get("IMILO_API_SECRET", None),
},
"structures_offres": {
"filename": "structures_offres.json",
"url": Variable.get("IMILO_API_URL", None),
"token": Variable.get("IMILO_API_SECRET", None),
},
},
},
Expand Down
12 changes: 3 additions & 9 deletions pipeline/dags/dag_utils/sources/imilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import requests

from airflow.models import Variable


class ImiloClient:
def __init__(self, base_url: str, secret: str) -> None:
Expand All @@ -12,6 +10,7 @@ def __init__(self, base_url: str, secret: str) -> None:
self.session.headers.update({"Content-Type": "application/json"})
self.secret = secret

# The token lasts 1h
def _get_token(self):
response = self.session.post(
url=f"{self.base_url}/get_token",
Expand All @@ -23,7 +22,7 @@ def _get_token(self):
)
response.raise_for_status()
self.session.headers.update(
{"Authorization": f"Bearer {response.json()["access_token"]}"}
{"Authorization": f"Bearer {response.json()['access_token']}"}
)

def _get_endpoint(
Expand All @@ -48,12 +47,7 @@ def list_structures_offres(self) -> list:
return self._get_endpoint("/get_structures_offres")


client = ImiloClient(
base_url=Variable.get("IMILO_API_URL"),
secret=Variable.get("IMILO_API_SECRET"),
)


def extract(id: str, url: str, token: str, **kwargs) -> bytes:
client = ImiloClient(base_url=url, secret=token)
data = getattr(client, f"list_{id}")()
return json.dumps(data).encode()

0 comments on commit acf2bee

Please sign in to comment.