-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: try grabbing query files from artifacts directory (#15776)
- Loading branch information
Showing
3 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 4.2.16 on 2025-01-27 12:19 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0200_delete_token_cleanup_job'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='EventQuery', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('fqcn', models.CharField(max_length=255)), | ||
('collection_version', models.CharField(max_length=32)), | ||
('event_query', models.JSONField(default=dict)), | ||
], | ||
options={ | ||
'unique_together': {('fqcn', 'collection_version')}, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.db import models | ||
|
||
from awx.main.models import BaseModel | ||
|
||
|
||
class EventQuery(BaseModel): | ||
""" | ||
Event queries are jq present in some collections and used to filter job events | ||
for indirectly created resources. | ||
""" | ||
|
||
class Meta: | ||
app_label = 'main' | ||
unique_together = ['fqcn', 'collection_version'] | ||
|
||
fqcn = models.CharField(max_length=255) | ||
collection_version = models.CharField(max_length=32) | ||
event_query = models.JSONField(default=dict) | ||
|
||
def validate_unique(self, exclude=None): | ||
try: | ||
EventQuery.objects.get(fqcn=self.fqcn, collection_version=self.collection_version) | ||
except EventQuery.DoesNotExist: | ||
return | ||
|
||
raise ValidationError(f'an event query for collection {self.fqcn}, version {self.collection_version} already exists') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters