generated from aws-ia/.github
-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AWS
committed
Jan 27, 2022
1 parent
0a53b53
commit 2906171
Showing
9 changed files
with
200 additions
and
115 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 |
---|---|---|
@@ -1 +1 @@ | ||
1.1.2 | ||
1.2.0 |
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
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,15 +1,37 @@ | ||
from typing import Literal, TypedDict | ||
|
||
|
||
class AftAccountInfo(TypedDict): | ||
id: str | ||
email: str | ||
name: str | ||
joined_method: str | ||
joined_date: str | ||
status: str | ||
parent_id: str | ||
parent_type: str | ||
org_name: str | ||
type: Literal["account"] | ||
vendor: Literal["aws"] | ||
from typing import TYPE_CHECKING, List, Optional | ||
|
||
from aft_common.aft_utils import get_logger | ||
from boto3.session import Session | ||
|
||
if TYPE_CHECKING: | ||
from mypy_boto3_servicecatalog import ServiceCatalogClient | ||
from mypy_boto3_servicecatalog.type_defs import ( | ||
DescribeProvisionedProductOutputTypeDef, | ||
ProvisionedProductDetailTypeDef, | ||
) | ||
else: | ||
ServiceCatalogClient = object | ||
DescribeProvisionedProductOutputTypeDef = object | ||
ProvisionedProductDetailTypeDef = object | ||
|
||
logger = get_logger() | ||
|
||
|
||
class Account: | ||
def __init__(self, ct_management_session: Session, account_name: str) -> None: | ||
self.ct_management_session = ct_management_session | ||
self.account_name = account_name | ||
|
||
@property | ||
def provisioned_product(self) -> Optional[ProvisionedProductDetailTypeDef]: | ||
client: ServiceCatalogClient = self.ct_management_session.client( | ||
"servicecatalog" | ||
) | ||
try: | ||
response: DescribeProvisionedProductOutputTypeDef = ( | ||
client.describe_provisioned_product(Name=self.account_name) | ||
) | ||
return response["ProvisionedProductDetail"] | ||
except client.exceptions.ResourceNotFoundException: | ||
logger.debug(f"Account with name {self.account_name} does not exists") | ||
return None |
Oops, something went wrong.