-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from D10S0VSkY-OSS/feature/advance_search
Feature/advance search
- Loading branch information
Showing
59 changed files
with
1,969 additions
and
708 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
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
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
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,38 @@ | ||
from fastapi import Depends, HTTPException | ||
from sqlalchemy.orm import Session | ||
|
||
from src.activityLogs.infrastructure import repositories as crud_activity | ||
from src.aws.domain.entities import aws as schemas_aws | ||
from src.aws.infrastructure import repositories as crud_aws | ||
from src.shared.security import deps | ||
from src.users.domain.entities import users as schemas_users | ||
from src.users.infrastructure import repositories as crud_users | ||
from src.shared.domain.exeptions.in_use import ResourceInUseError | ||
|
||
|
||
async def update_aws_account( | ||
aws_account_id: int, | ||
aws: schemas_aws.AwsAccountUpdate, | ||
current_user: schemas_users.User = Depends(deps.get_current_active_user), | ||
db: Session = Depends(deps.get_db), | ||
) -> schemas_aws.AwsAsumeProfile: | ||
if not crud_users.is_master(db, current_user): | ||
raise HTTPException(status_code=403, detail="Not enough permissions") | ||
try: | ||
filters = schemas_aws.AwsAccountFilter() | ||
filters.id = aws_account_id | ||
db_aws_account = await crud_aws.get_all_aws_profile(db=db, filters=filters) | ||
if not db_aws_account: | ||
raise HTTPException(status_code=404, detail="Account not found") | ||
result = await crud_aws.update_aws_profile(db=db, aws_account_id=aws_account_id, updated_aws=aws) | ||
crud_activity.create_activity_log( | ||
db=db, | ||
username=current_user.username, | ||
squad=current_user.squad, | ||
action=f"Update AWS account {aws.squad} {aws.environment}", | ||
) | ||
return result | ||
except ResourceInUseError as err: | ||
raise HTTPException(status_code=409, detail=str(err)) | ||
except Exception as err: | ||
raise err |
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
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 |
---|---|---|
@@ -1,35 +1,70 @@ | ||
from typing import Optional | ||
import datetime | ||
from typing import Optional, Dict, Any | ||
|
||
from pydantic import BaseModel, Field, constr | ||
from pydantic import BaseModel, constr, SecretStr | ||
|
||
|
||
class AwsBase(BaseModel): | ||
squad: constr(strip_whitespace=True) | ||
environment: constr(strip_whitespace=True) | ||
access_key_id: constr(strip_whitespace=True) | ||
secret_access_key: Optional[constr(strip_whitespace=True)] = Field( | ||
None, example="string" | ||
) | ||
secret_access_key: constr(strip_whitespace=True) | ||
default_region: constr(strip_whitespace=True) | ||
extra_variables: Optional[Dict[str, Any]] = None | ||
|
||
default_region: constr(strip_whitespace=True) | ||
|
||
class AwsAsumeProfile(AwsBase): | ||
profile_name: Optional[constr(strip_whitespace=True)] = None | ||
role_arn: Optional[constr(strip_whitespace=True)] = None | ||
source_profile: Optional[constr(strip_whitespace=True)] = None | ||
|
||
|
||
class Aws(AwsBase): | ||
id: int | ||
class AwsId(BaseModel): | ||
id: Optional[int] = None | ||
|
||
class Config: | ||
from_attributes = True | ||
|
||
class AwsAccountResponse(BaseModel): | ||
|
||
class AwsAccountResponseBase(BaseModel): | ||
id: int | ||
squad: constr(strip_whitespace=True) | ||
environment: constr(strip_whitespace=True) | ||
profile_name: Optional[constr(strip_whitespace=True)] = None | ||
role_arn: Optional[constr(strip_whitespace=True)] = None | ||
source_profile: Optional[constr(strip_whitespace=True)] = None | ||
squad: str | ||
environment: str | ||
default_region: Optional[str] | ||
role_arn: Optional[str] | ||
created_at: Optional[datetime.datetime] = None | ||
updated_at: Optional[datetime.datetime] = None | ||
|
||
class Config: | ||
from_attributes = True | ||
|
||
|
||
class AwsAccountResponse(AwsAccountResponseBase): | ||
extra_variables: Optional[Dict[str, SecretStr]] | ||
|
||
class Config: | ||
from_attributes = True | ||
|
||
|
||
class AwsAccountResponseRepo(AwsAccountResponseBase): | ||
access_key_id: str | ||
secret_access_key: str | ||
extra_variables: Optional[Dict[str, Any]] = None | ||
|
||
class Config: | ||
from_attributes = True | ||
|
||
|
||
class AwsAccount(BaseModel): | ||
squad: Optional[str] = None | ||
environment: Optional[str] = None | ||
default_region: Optional[str] = None | ||
role_arn: Optional[str] = None | ||
access_key_id: Optional[str] = None | ||
|
||
|
||
class AwsAccountFilter(AwsAccount, AwsId): | ||
pass | ||
|
||
|
||
class AwsAccountUpdate(AwsAccount): | ||
secret_access_key: Optional[str] = None | ||
extra_variables: Optional[Dict[str, Any]] = None |
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
Oops, something went wrong.