Skip to content

Commit

Permalink
Merge branch 'fix/patch-method' into 'master'
Browse files Browse the repository at this point in the history
fix update job endpoint caused by reserved word "plan"

Closes openeo-platform#215

See merge request team-6/openeo-sentinelhub-python-driver!323
  • Loading branch information
guss84 committed Oct 23, 2023
2 parents bb9b480 + 87d5bd9 commit 8440b31
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rest/dynamodb/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
FAKE_AWS_ACCESS_KEY_ID = "AKIAIOSFODNN7EXAMPLE"
FAKE_AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"

USED_RESERVED_WORDS = ["plan"]


class DeploymentTypes(Enum):
PRODUCTION = "production"
Expand Down Expand Up @@ -121,12 +123,17 @@ def update_key(cls, record_id, key, new_value):
else:
new_value = str(new_value)

updated_item = cls.dynamodb.update_item(
kwargs = dict(
TableName=cls.TABLE_NAME,
Key={"id": {"S": record_id}},
UpdateExpression="SET {} = :new_content".format(key),
ExpressionAttributeValues={":new_content": {data_type: new_value}},
)
if key in USED_RESERVED_WORDS:
kwargs["UpdateExpression"] = "SET #{} = :new_content".format(key)
kwargs["ExpressionAttributeNames"] = {"#{}".format(key): "{}".format(key)}

updated_item = cls.dynamodb.update_item(**kwargs)
return updated_item

@classmethod
Expand Down Expand Up @@ -316,7 +323,6 @@ def create(cls, data):


if __name__ == "__main__":

# To create tables, run:
# $ pipenv shell
# <shell> $ DEPLOYMENT_TYPE="production" ./dynamodb.py
Expand Down

0 comments on commit 8440b31

Please sign in to comment.