Skip to content

Commit

Permalink
Merge pull request #19 from port-labs/PORT-4691-aws-exporter-scale-im…
Browse files Browse the repository at this point in the history
…provements-fix

Fix pop bug
  • Loading branch information
talsabagport authored Sep 12, 2023
2 parents 987d59e + 43630da commit 2bb2a6d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lambda_function/port/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@ def get_token(self, client_id, client_secret):
return token_response.json()["accessToken"]

def upsert_entity(self, entity):
blueprint_id = entity.pop("blueprint")
blueprint_id = entity.get("blueprint")
entity_to_upsert = {k: v for k, v in entity.items() if k != 'blueprint'}
logger.info(
f"Upsert entity: {entity.get('identifier')} of blueprint: {blueprint_id}"
f"Upsert entity: {entity_to_upsert.get('identifier')} of blueprint: {blueprint_id}"
)
requests.post(
f'{self.api_url}/blueprints/{urllib.parse.quote(blueprint_id, safe="")}/entities',
json=entity,
json=entity_to_upsert,
headers=self.headers,
params={"upsert": "true", "merge": "true"},
).raise_for_status()

def delete_entity(self, entity):
blueprint_id = entity.pop("blueprint")
entity_id = entity.pop("identifier")
blueprint_id = entity.get("blueprint")
entity_id = entity.get("identifier")
logger.info(f"Delete entity: {entity_id} of blueprint: {blueprint_id}")
requests.delete(
f'{self.api_url}/blueprints/{urllib.parse.quote(blueprint_id, safe="")}/entities/{urllib.parse.quote(entity_id, safe="")}',
Expand Down

0 comments on commit 2bb2a6d

Please sign in to comment.