Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork Sync: Update from parent repository #204

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/cli/onefuzz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import uuid
from enum import Enum
from shutil import which
from typing import Callable, Dict, List, Optional, Tuple, Type, TypeVar
from typing import Callable, Dict, List, Optional, Tuple, Type, TypeVar, Union
from urllib.parse import urlparse
from uuid import UUID

Expand Down Expand Up @@ -859,6 +859,30 @@ def list(
data=requests.NotificationSearch(container=container),
)

def migrate_jinja_to_scriban(
self, dry_run: bool = False
) -> Union[
responses.JinjaToScribanMigrationResponse,
responses.JinjaToScribanMigrationDryRunResponse,
]:
"""Migrates all notification templates from jinja to scriban"""

migration_endpoint = "migrations/jinja_to_scriban"
if dry_run:
return self._req_model(
"POST",
responses.JinjaToScribanMigrationDryRunResponse,
data=requests.JinjaToScribanMigrationPost(dry_run=dry_run),
alternate_endpoint=migration_endpoint,
)
else:
return self._req_model(
"POST",
responses.JinjaToScribanMigrationResponse,
data=requests.JinjaToScribanMigrationPost(dry_run=dry_run),
alternate_endpoint=migration_endpoint,
)


class Tasks(Endpoint):
"""Interact with tasks"""
Expand Down
4 changes: 4 additions & 0 deletions src/pytypes/onefuzztypes/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,8 @@ class TemplateValidationPost(BaseModel):
context: Optional[TemplateRenderContext]


class JinjaToScribanMigrationPost(BaseModel):
dry_run: bool = Field(default=False)


_check_hotfix()
9 changes: 9 additions & 0 deletions src/pytypes/onefuzztypes/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,12 @@ class CanSchedule(BaseResponse):
class TemplateValidationResponse(BaseResponse):
rendered_template: str
available_context: TemplateRenderContext


class JinjaToScribanMigrationResponse(BaseResponse):
updated_notification_ids: List[UUID]
failed_notification_ids: List[UUID]


class JinjaToScribanMigrationDryRunResponse(BaseResponse):
notification_ids_to_update: List[UUID]