Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
pehlicd committed Apr 2, 2024
2 parents 3d7fd51 + dbd8628 commit 900ec28
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# CHANGELOG
{% if context.history.unreleased | length > 0 %}

{# UNRELEASED #}
## Unreleased
{% for type_, commits in context.history.unreleased | dictsort %}
### {{ type_ | capitalize }}
{% for commit in commits %}{% if type_ != "unknown" %}
* {{ commit.commit.message.rstrip() }} ([`{{ commit.commit.hexsha[:7] }}`]({{ commit.commit.hexsha | commit_hash_url }}))
{% else %}
* {{ commit.commit.message.rstrip() }} ([`{{ commit.commit.hexsha[:7] }}`]({{ commit.commit.hexsha | commit_hash_url }}))
{% endif %}{% endfor %}{% endfor %}

{% endif %}

{# RELEASED #}
{% for version, release in context.history.released.items() %}
## {{ version.as_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }})
{% for type_, commits in release["elements"] | dictsort %}
### {{ type_ | capitalize }}
{% for commit in commits %}{% if type_ != "unknown" %}
* {{ commit.commit.message.rstrip() }} ([`{{ commit.commit.hexsha[:7] }}`]({{ commit.commit.hexsha | commit_hash_url }}))
{% else %}
* {{ commit.commit.message.rstrip() }} ([`{{ commit.commit.hexsha[:7] }}`]({{ commit.commit.hexsha | commit_hash_url }}))
{% endif %}{% endfor %}{% endfor %}{% endfor %}
29 changes: 21 additions & 8 deletions keep/api/routes/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

from keep.api.core.db import get_session
from keep.api.core.dependencies import AuthenticatedEntity, AuthVerifier
from keep.api.models.db.mapping import MappingRule, MappingRuleDtoIn, MappingRuleDtoOut, MappingRuleDtoUpdate
from keep.api.models.db.mapping import (
MappingRule,
MappingRuleDtoIn,
MappingRuleDtoOut,
MappingRuleDtoUpdate,
)

router = APIRouter()

Expand Down Expand Up @@ -82,12 +87,20 @@ def delete_rule(


@router.put("", description="Update an existing rule")
def update_rule(rule: MappingRuleDtoUpdate,
authenticated_entity: AuthenticatedEntity = Depends(AuthVerifier(["write:rules"])),
session: Session = Depends(get_session)) -> MappingRuleDtoOut:
def update_rule(
rule: MappingRuleDtoUpdate,
authenticated_entity: AuthenticatedEntity = Depends(AuthVerifier(["write:rules"])),
session: Session = Depends(get_session),
) -> MappingRuleDtoOut:
logger.info("Updating a mapping rule")
existing_rule: MappingRule = session.query(MappingRule).filter(
MappingRule.tenant_id == authenticated_entity.tenant_id and MappingRule.id == rule.id).first()
existing_rule: MappingRule = (
session.query(MappingRule)
.filter(
MappingRule.tenant_id == authenticated_entity.tenant_id,
MappingRule.id == rule.id,
)
.first()
)
if existing_rule is None:
raise HTTPException(status_code=404, detail="Rule not found")
existing_rule.name = rule.name
Expand All @@ -102,6 +115,6 @@ def update_rule(rule: MappingRuleDtoUpdate,
response = MappingRuleDtoOut(**existing_rule.dict())
if rule.rows is not None:
response.attributes = [
key for key in existing_rule.rows[0].keys() if key not in rule.matchers
]
key for key in existing_rule.rows[0].keys() if key not in rule.matchers
]
return response

0 comments on commit 900ec28

Please sign in to comment.