day2 0.2.4__tar.gz → 0.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {day2-0.2.4 → day2-0.2.6}/PKG-INFO +1 -1
- {day2-0.2.4 → day2-0.2.6}/day2/exceptions.py +8 -0
- {day2-0.2.4 → day2-0.2.6}/day2/models/__init__.py +32 -0
- {day2-0.2.4 → day2-0.2.6}/day2/models/assessment.py +13 -7
- day2-0.2.6/day2/models/bot.py +124 -0
- {day2-0.2.4 → day2-0.2.6}/day2/models/report.py +30 -1
- day2-0.2.6/day2/models/resource.py +144 -0
- {day2-0.2.4 → day2-0.2.6}/day2/resources/__init__.py +10 -1
- {day2-0.2.4 → day2-0.2.6}/day2/resources/assessment.py +4 -2
- day2-0.2.6/day2/resources/bot.py +163 -0
- {day2-0.2.4 → day2-0.2.6}/day2/resources/report.py +38 -0
- day2-0.2.6/day2/resources/resource.py +151 -0
- {day2-0.2.4 → day2-0.2.6}/day2/resources/tenant.py +2 -2
- {day2-0.2.4 → day2-0.2.6}/day2/session.py +32 -2
- {day2-0.2.4 → day2-0.2.6}/day2.egg-info/PKG-INFO +1 -1
- {day2-0.2.4 → day2-0.2.6}/day2.egg-info/SOURCES.txt +6 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/cli.py +4 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/commands/__init__.py +12 -1
- {day2-0.2.4 → day2-0.2.6}/day2_cli/commands/assessment.py +36 -14
- day2-0.2.6/day2_cli/commands/bot.py +258 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/commands/cost.py +4 -4
- {day2-0.2.4 → day2-0.2.6}/day2_cli/commands/report.py +54 -4
- day2-0.2.6/day2_cli/commands/resource.py +243 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/commands/tenant.py +15 -10
- {day2-0.2.4 → day2-0.2.6}/day2_cli/utils/exit_codes.py +3 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/utils/formatters.py +3 -0
- {day2-0.2.4 → day2-0.2.6}/pyproject.toml +1 -1
- {day2-0.2.4 → day2-0.2.6}/LICENSE +0 -0
- {day2-0.2.4 → day2-0.2.6}/README.md +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/__init__.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/_version.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/auth/__init__.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/auth/credentials.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/client/__init__.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/client/base.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/client/config.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/client/constants.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/client/profile.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/client/user_context.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/models/cost.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/models/tenant.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/resources/cost.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/resources/user.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/utils/__init__.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2/utils/helpers.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2.egg-info/dependency_links.txt +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2.egg-info/entry_points.txt +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2.egg-info/requires.txt +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2.egg-info/top_level.txt +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/__init__.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/commands/auth.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/commands/profile.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/utils/__init__.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/utils/context.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/day2_cli/utils/output_formatter.py +0 -0
- {day2-0.2.4 → day2-0.2.6}/setup.cfg +0 -0
- {day2-0.2.4 → day2-0.2.6}/tests/test_exceptions.py +0 -0
|
@@ -53,3 +53,11 @@ class TenantContextError(ClientError):
|
|
|
53
53
|
self, message: str, status_code: int = 400, request_id: Optional[str] = None
|
|
54
54
|
):
|
|
55
55
|
super().__init__(message, status_code, request_id)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class ProfileNotFoundError(Day2Error):
|
|
59
|
+
"""Raised when a specified profile is not found."""
|
|
60
|
+
|
|
61
|
+
def __init__(self, profile_name: str):
|
|
62
|
+
self.profile_name = profile_name
|
|
63
|
+
super().__init__(f"Profile '{profile_name}' not found")
|
|
@@ -11,12 +11,30 @@ from day2.models.assessment import (
|
|
|
11
11
|
RunAssessmentInput,
|
|
12
12
|
RunAssessmentOutput,
|
|
13
13
|
)
|
|
14
|
+
from day2.models.bot import (
|
|
15
|
+
ComplianceBotFinding,
|
|
16
|
+
ListComplianceBotFindingsOutput,
|
|
17
|
+
ListComplianceBotPolicyGroupsOutput,
|
|
18
|
+
ListComplianceBotResourceTypesOutput,
|
|
19
|
+
Policy,
|
|
20
|
+
ResourceType,
|
|
21
|
+
)
|
|
14
22
|
from day2.models.cost import GetCostByChargeTypeOutput
|
|
15
23
|
from day2.models.report import (
|
|
24
|
+
DeleteReportInput,
|
|
25
|
+
DeleteReportOutput,
|
|
16
26
|
GetReportDetailsOutput,
|
|
17
27
|
GetReportOutput,
|
|
18
28
|
ListReportsOutput,
|
|
19
29
|
)
|
|
30
|
+
from day2.models.resource import (
|
|
31
|
+
GetInventorySummaryOutput,
|
|
32
|
+
InventorySummaryByAccountNumber,
|
|
33
|
+
InventorySummaryByRegion,
|
|
34
|
+
InventorySummaryByResourceType,
|
|
35
|
+
ListRegionsOutput,
|
|
36
|
+
ListResourceTypesOutput,
|
|
37
|
+
)
|
|
20
38
|
from day2.models.tenant import ListTenantsOutput, TenantDetails
|
|
21
39
|
|
|
22
40
|
__all__ = [
|
|
@@ -35,4 +53,18 @@ __all__ = [
|
|
|
35
53
|
"GetReportDetailsOutput",
|
|
36
54
|
"GetReportOutput",
|
|
37
55
|
"ListReportsOutput",
|
|
56
|
+
"Policy",
|
|
57
|
+
"ResourceType",
|
|
58
|
+
"ComplianceBotFinding",
|
|
59
|
+
"ListComplianceBotFindingsOutput",
|
|
60
|
+
"ListComplianceBotResourceTypesOutput",
|
|
61
|
+
"ListComplianceBotPolicyGroupsOutput",
|
|
62
|
+
"GetInventorySummaryOutput",
|
|
63
|
+
"ListRegionsOutput",
|
|
64
|
+
"ListResourceTypesOutput",
|
|
65
|
+
"InventorySummaryByAccountNumber",
|
|
66
|
+
"InventorySummaryByRegion",
|
|
67
|
+
"InventorySummaryByResourceType",
|
|
68
|
+
"DeleteReportInput",
|
|
69
|
+
"DeleteReportOutput",
|
|
38
70
|
]
|
|
@@ -18,6 +18,7 @@ class Assessment(BaseModel):
|
|
|
18
18
|
answered_questions: Number of questions that have been answered
|
|
19
19
|
created_at: Timestamp when the assessment was created
|
|
20
20
|
updated_at: Timestamp when the assessment was last updated
|
|
21
|
+
last_run_at: Timestamp of the last execution run (if completed)
|
|
21
22
|
"""
|
|
22
23
|
|
|
23
24
|
id: str = Field(alias="AssessmentId")
|
|
@@ -30,6 +31,7 @@ class Assessment(BaseModel):
|
|
|
30
31
|
answered_questions: int = Field(alias="AnsweredQuestions")
|
|
31
32
|
created_at: Optional[datetime] = Field(None, alias="CreatedAt")
|
|
32
33
|
updated_at: Optional[datetime] = Field(None, alias="UpdatedAt")
|
|
34
|
+
last_run_at: Optional[datetime] = Field(None, alias="LastRunAt")
|
|
33
35
|
|
|
34
36
|
# Allow extra fields
|
|
35
37
|
model_config = ConfigDict(extra="allow")
|
|
@@ -334,11 +336,6 @@ class GetQuestionOutput(BaseModel):
|
|
|
334
336
|
def __init__(self, **data: Any) -> None:
|
|
335
337
|
super().__init__(**data)
|
|
336
338
|
|
|
337
|
-
# Set is_answered based on risk
|
|
338
|
-
self.is_answered = (
|
|
339
|
-
self.risk is not None and self.risk != "UNANSWERED" and self.risk != ""
|
|
340
|
-
)
|
|
341
|
-
|
|
342
339
|
# Process choice_answers to handle both string and dictionary formats
|
|
343
340
|
processed_choice_answers: List[str] = []
|
|
344
341
|
for choice in self.choice_answers:
|
|
@@ -355,6 +352,9 @@ class GetQuestionOutput(BaseModel):
|
|
|
355
352
|
# Set selected_choices as an alias for choice_answers
|
|
356
353
|
self.selected_choices = processed_choice_answers
|
|
357
354
|
|
|
355
|
+
# Set is_answered based on whether selected_choices has items
|
|
356
|
+
self.is_answered = bool(self.selected_choices)
|
|
357
|
+
|
|
358
358
|
|
|
359
359
|
class ChoiceStatus(BaseModel):
|
|
360
360
|
"""Status of a choice in an answer.
|
|
@@ -561,12 +561,13 @@ class GenerateAssessmentReportInput(BaseModel):
|
|
|
561
561
|
cloud_provider: Cloud provider name (default: AWS).
|
|
562
562
|
pillar_ids: List of pillar IDs to filter findings. Allowed values: security, costOptimization,
|
|
563
563
|
reliability, performance, operationalExcellence, sustainability.
|
|
564
|
-
severity: List of severity levels to filter findings.
|
|
565
|
-
status: List of statuses to filter findings.
|
|
564
|
+
severity: List of severity levels to filter findings. Allowed values: High, Critical, Medium, Low, Informational.
|
|
565
|
+
status: List of statuses to filter findings. Allowed values: Failed, Error, Suppressed, Passed.
|
|
566
566
|
account_number: List of AWS account numbers to filter findings.
|
|
567
567
|
region_code: List of AWS region codes to filter findings.
|
|
568
568
|
unique_report: Whether to return unique findings in the report (default: False).
|
|
569
569
|
lenses: List of well-architected lenses to filter findings.
|
|
570
|
+
best_practice_risk_exposure: List of best practice risk exposures to filter findings. Allowed values: High, Medium, Low.
|
|
570
571
|
"""
|
|
571
572
|
|
|
572
573
|
cloud_provider: str = Field(
|
|
@@ -607,6 +608,11 @@ class GenerateAssessmentReportInput(BaseModel):
|
|
|
607
608
|
alias="Lenses",
|
|
608
609
|
description="List of well-architected lenses to filter findings.",
|
|
609
610
|
)
|
|
611
|
+
best_practice_risk_exposure: Optional[List[str]] = Field(
|
|
612
|
+
default=None,
|
|
613
|
+
alias="BestPracticeRiskExposure",
|
|
614
|
+
description="List of best practice risk exposures to filter findings.",
|
|
615
|
+
)
|
|
610
616
|
|
|
611
617
|
# Allow extra fields
|
|
612
618
|
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Policy(BaseModel):
|
|
8
|
+
"""
|
|
9
|
+
Details of a policy associated with a compliance finding.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
policy_group: The group this policy belongs to.
|
|
13
|
+
policy_id: The unique identifier for the policy.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
policy_group: str = Field(..., alias="PolicyGroup")
|
|
17
|
+
policy_id: str = Field(..., alias="PolicyId")
|
|
18
|
+
|
|
19
|
+
# Allow extra fields
|
|
20
|
+
model_config = ConfigDict(extra="allow")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ComplianceBotFinding(BaseModel):
|
|
24
|
+
"""
|
|
25
|
+
Details of a Compliance Bot finding.
|
|
26
|
+
|
|
27
|
+
Attributes:
|
|
28
|
+
account_number: AWS account number where the finding was detected.
|
|
29
|
+
compliance_type: The compliance type. Allowed values: "Non-Compliant", "Compliant".
|
|
30
|
+
config_rule_invoked_time: The time the config rule was invoked.
|
|
31
|
+
config_rule_name: Name of the AWS Config rule.
|
|
32
|
+
created_at: Timestamp when the finding was created.
|
|
33
|
+
description: Description of the finding.
|
|
34
|
+
id: Unique identifier for the finding.
|
|
35
|
+
metadata: Additional metadata for the finding.
|
|
36
|
+
policies: List of associated policies.
|
|
37
|
+
region_code: AWS region code.
|
|
38
|
+
remediation_task_exists: Whether a remediation task exists for this finding.
|
|
39
|
+
resource_id: ID of the affected resource.
|
|
40
|
+
resource_type: Type of the affected resource.
|
|
41
|
+
result_recorded_time: The time the result was recorded.
|
|
42
|
+
updated_at: Timestamp when the finding was last updated.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
account_number: str = Field(..., alias="AccountNumber")
|
|
46
|
+
compliance_type: str = Field(..., alias="ComplianceType")
|
|
47
|
+
config_rule_invoked_time: datetime = Field(..., alias="ConfigRuleInvokedTime")
|
|
48
|
+
config_rule_name: str = Field(..., alias="ConfigRuleName")
|
|
49
|
+
created_at: datetime = Field(..., alias="CreatedAt")
|
|
50
|
+
description: str = Field(..., alias="Description")
|
|
51
|
+
id: str = Field(..., alias="Id")
|
|
52
|
+
metadata: str = Field(..., alias="Metadata")
|
|
53
|
+
policies: List[Policy] = Field(..., alias="Policies")
|
|
54
|
+
region_code: str = Field(..., alias="RegionCode")
|
|
55
|
+
remediation_task_exists: bool = Field(..., alias="RemediationTaskExists")
|
|
56
|
+
resource_id: str = Field(..., alias="ResourceId")
|
|
57
|
+
resource_type: str = Field(..., alias="ResourceType")
|
|
58
|
+
result_recorded_time: datetime = Field(..., alias="ResultRecordedTime")
|
|
59
|
+
updated_at: datetime = Field(..., alias="UpdatedAt")
|
|
60
|
+
|
|
61
|
+
# Allow extra fields
|
|
62
|
+
model_config = ConfigDict(extra="allow")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class ListComplianceBotFindingsOutput(BaseModel):
|
|
66
|
+
"""
|
|
67
|
+
Output model for the list_compliance_bot_findings operation.
|
|
68
|
+
|
|
69
|
+
Attributes:
|
|
70
|
+
page_number: The current page number of the results.
|
|
71
|
+
has_more: Whether there are more findings to retrieve.
|
|
72
|
+
findings: List of Compliance Bot findings.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
page_number: int = Field(..., alias="PageNumber")
|
|
76
|
+
has_more: bool = Field(..., alias="HasMore")
|
|
77
|
+
findings: List[ComplianceBotFinding] = Field(..., alias="Findings")
|
|
78
|
+
|
|
79
|
+
# Allow extra fields
|
|
80
|
+
model_config = ConfigDict(extra="allow")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class ResourceType(BaseModel):
|
|
84
|
+
"""
|
|
85
|
+
Details of a resource type supported by the Compliance Bot.
|
|
86
|
+
|
|
87
|
+
Attributes:
|
|
88
|
+
label: The display label for the resource type.
|
|
89
|
+
resource_type: The resource type identifier.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
label: str = Field(..., alias="Label")
|
|
93
|
+
resource_type: str = Field(..., alias="ResourceType")
|
|
94
|
+
|
|
95
|
+
# Allow extra fields
|
|
96
|
+
model_config = ConfigDict(extra="allow")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class ListComplianceBotResourceTypesOutput(BaseModel):
|
|
100
|
+
"""
|
|
101
|
+
Output model for the list_compliance_bot_resource_types operation.
|
|
102
|
+
|
|
103
|
+
Attributes:
|
|
104
|
+
resource_types: List of resource types supported by the Compliance Bot.
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
resource_types: List[ResourceType] = Field(..., alias="ResourceTypes")
|
|
108
|
+
|
|
109
|
+
# Allow extra fields
|
|
110
|
+
model_config = ConfigDict(extra="allow")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class ListComplianceBotPolicyGroupsOutput(BaseModel):
|
|
114
|
+
"""
|
|
115
|
+
Output model for the list_compliance_bot_policy_groups operation.
|
|
116
|
+
|
|
117
|
+
Attributes:
|
|
118
|
+
policy_groups: List of policy groups.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
policy_groups: List[str] = Field(..., alias="PolicyGroups")
|
|
122
|
+
|
|
123
|
+
# Allow extra fields
|
|
124
|
+
model_config = ConfigDict(extra="allow")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
|
-
from pydantic import BaseModel, ConfigDict, Field
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class GetReportDetailsOutput(BaseModel):
|
|
@@ -71,3 +71,32 @@ class ListReportsOutput(BaseModel):
|
|
|
71
71
|
"""
|
|
72
72
|
|
|
73
73
|
reports: List[ReportItem] = Field(alias="Records", default=[])
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class DeleteReportInput(BaseModel):
|
|
77
|
+
"""Pydantic model for input of Delete Report API.
|
|
78
|
+
|
|
79
|
+
Attributes:
|
|
80
|
+
report_ids: List of report IDs to be deleted.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
report_ids: List[str]
|
|
84
|
+
|
|
85
|
+
@field_validator("report_ids")
|
|
86
|
+
@classmethod
|
|
87
|
+
def validate_report_ids(cls, v: List[str]) -> List[str]:
|
|
88
|
+
if not v or len(v) < 1:
|
|
89
|
+
raise ValueError("At least 1 report ID must be provided.")
|
|
90
|
+
if len(v) > 100:
|
|
91
|
+
raise ValueError("A maximum of 100 report IDs can be deleted at once.")
|
|
92
|
+
return v
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class DeleteReportOutput(BaseModel):
|
|
96
|
+
"""Pydantic model for output of Delete Report API.
|
|
97
|
+
|
|
98
|
+
Attributes:
|
|
99
|
+
message: Confirmation message after deletion.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
message: str
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"""Resource models for the MontyCloud DAY2 API."""
|
|
2
|
+
|
|
3
|
+
from typing import List, Union
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ResourceTypeItem(BaseModel):
|
|
9
|
+
"""Represents a single resource type entry returned by list_resource_types operation.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
label: Display label for the resource type.
|
|
13
|
+
resource_type: Resource type identifier.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
model_config = ConfigDict(extra="allow")
|
|
17
|
+
|
|
18
|
+
label: str = Field(alias="Label", description="Display label for the resource type")
|
|
19
|
+
resource_type: str = Field(
|
|
20
|
+
alias="ResourceType", description="Resource type identifier"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ListResourceTypesOutput(BaseModel):
|
|
25
|
+
"""Output model for list_resource_types operation.
|
|
26
|
+
|
|
27
|
+
Attributes:
|
|
28
|
+
resource_types: List of resource type entries containing label and identifier.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
model_config = ConfigDict(extra="allow")
|
|
32
|
+
|
|
33
|
+
resource_types: List[ResourceTypeItem] = Field(
|
|
34
|
+
alias="ResourceTypes",
|
|
35
|
+
description="List of resource type entries containing label and identifier",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class RegionItem(BaseModel):
|
|
40
|
+
"""Represents a single region entry returned by list_regions operation.
|
|
41
|
+
|
|
42
|
+
Attributes:
|
|
43
|
+
label: Display label for the region.
|
|
44
|
+
region_code: Region code identifier (e.g., 'us-east-1').
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
model_config = ConfigDict(extra="allow")
|
|
48
|
+
|
|
49
|
+
label: str = Field(alias="Label", description="Display label for the region")
|
|
50
|
+
region_code: str = Field(
|
|
51
|
+
alias="RegionCode", description="Region code identifier (e.g., 'us-east-1')"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class ListRegionsOutput(BaseModel):
|
|
56
|
+
"""Output model for list_regions operation.
|
|
57
|
+
|
|
58
|
+
Attributes:
|
|
59
|
+
regions: List of region entries with code and label.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
model_config = ConfigDict(extra="allow")
|
|
63
|
+
|
|
64
|
+
regions: List[RegionItem] = Field(
|
|
65
|
+
alias="Regions", description="List of regions with code and label"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class InventorySummaryByResourceType(BaseModel):
|
|
70
|
+
"""Summary of inventory by resource type.
|
|
71
|
+
|
|
72
|
+
Attributes:
|
|
73
|
+
resource_type: The type of the resource.
|
|
74
|
+
resource_count: The number of resources of this type.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
model_config = ConfigDict(extra="allow")
|
|
78
|
+
|
|
79
|
+
resource_type: str = Field(
|
|
80
|
+
..., alias="ResourceType", description="The type of the resource."
|
|
81
|
+
)
|
|
82
|
+
resource_count: int = Field(
|
|
83
|
+
..., alias="ResourceCount", description="The number of resources of this type."
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class InventorySummaryByRegion(BaseModel):
|
|
88
|
+
"""Summary of inventory by region.
|
|
89
|
+
|
|
90
|
+
Attributes:
|
|
91
|
+
region_code: The AWS region code (e.g., us-east-1).
|
|
92
|
+
resource_count: The number of resources in this region.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
model_config = ConfigDict(extra="allow")
|
|
96
|
+
|
|
97
|
+
region_code: str = Field(
|
|
98
|
+
..., alias="RegionCode", description="The AWS region code."
|
|
99
|
+
)
|
|
100
|
+
resource_count: int = Field(
|
|
101
|
+
...,
|
|
102
|
+
alias="ResourceCount",
|
|
103
|
+
description="The number of resources in this region.",
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class InventorySummaryByAccountNumber(BaseModel):
|
|
108
|
+
"""Summary of inventory by account.
|
|
109
|
+
|
|
110
|
+
Attributes:
|
|
111
|
+
account_number: The AWS account number.
|
|
112
|
+
resource_count: The number of resources in this account.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
model_config = ConfigDict(extra="allow")
|
|
116
|
+
|
|
117
|
+
account_number: str = Field(
|
|
118
|
+
..., alias="AccountNumber", description="The AWS account number."
|
|
119
|
+
)
|
|
120
|
+
resource_count: int = Field(
|
|
121
|
+
...,
|
|
122
|
+
alias="ResourceCount",
|
|
123
|
+
description="The number of resources in this account.",
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class GetInventorySummaryOutput(BaseModel):
|
|
128
|
+
"""Output model for get_inventory_summary operation.
|
|
129
|
+
|
|
130
|
+
Attributes:
|
|
131
|
+
inventory_summary: List of inventory summaries by resource type, region, or account.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
model_config = ConfigDict(extra="allow")
|
|
135
|
+
|
|
136
|
+
inventory_summary: Union[
|
|
137
|
+
List[InventorySummaryByResourceType],
|
|
138
|
+
List[InventorySummaryByRegion],
|
|
139
|
+
List[InventorySummaryByAccountNumber],
|
|
140
|
+
] = Field(
|
|
141
|
+
default=[],
|
|
142
|
+
alias="InventorySummary",
|
|
143
|
+
description="List of inventory summaries by resource type, region, or account.",
|
|
144
|
+
)
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"""Resource implementations for the MontyCloud DAY2 SDK."""
|
|
2
2
|
|
|
3
3
|
from day2.resources.assessment import AssessmentClient
|
|
4
|
+
from day2.resources.bot import BotClient
|
|
4
5
|
from day2.resources.cost import CostClient
|
|
5
6
|
from day2.resources.report import ReportClient
|
|
7
|
+
from day2.resources.resource import ResourceClient
|
|
6
8
|
from day2.resources.tenant import TenantClient
|
|
7
9
|
|
|
8
|
-
__all__ = [
|
|
10
|
+
__all__ = [
|
|
11
|
+
"TenantClient",
|
|
12
|
+
"AssessmentClient",
|
|
13
|
+
"CostClient",
|
|
14
|
+
"ReportClient",
|
|
15
|
+
"BotClient",
|
|
16
|
+
"ResourceClient",
|
|
17
|
+
]
|
|
@@ -349,7 +349,7 @@ class AssessmentClient(BaseClient):
|
|
|
349
349
|
resource_ids: Optional list of resource IDs to filter findings by.
|
|
350
350
|
pillar_ids: Optional list of pillar IDs to filter findings by. Allowed values: security, costOptimization,
|
|
351
351
|
reliability, performance, operationalExcellence, sustainability.
|
|
352
|
-
page_size: The number of findings per page (default: 10).
|
|
352
|
+
page_size: The number of findings per page (default: 10, valid range: 1-100).
|
|
353
353
|
page_token: Token for pagination.
|
|
354
354
|
|
|
355
355
|
Returns:
|
|
@@ -496,12 +496,13 @@ class AssessmentClient(BaseClient):
|
|
|
496
496
|
>>> data = GenerateAssessmentReportInput(
|
|
497
497
|
... cloud_provider="AWS",
|
|
498
498
|
... pillar_ids=["security", "reliability"],
|
|
499
|
-
... severity=["
|
|
499
|
+
... severity=["High", "Medium"],
|
|
500
500
|
... status=["Failed"],
|
|
501
501
|
... account_number=["123456789012"],
|
|
502
502
|
... region_code=["us-east-1", "us-west-2"],
|
|
503
503
|
... unique_report=True,
|
|
504
504
|
... lenses=["AWS Well-Architected Framework"]
|
|
505
|
+
... best_practice_risk_exposure=["High", "Medium"]
|
|
505
506
|
... )
|
|
506
507
|
>>> response = client.generate_report("tenant-123", "assessment-123", data)
|
|
507
508
|
>>> print(f"Report ID: {response.report_id}")
|
|
@@ -516,6 +517,7 @@ class AssessmentClient(BaseClient):
|
|
|
516
517
|
"RegionCode": data.region_code,
|
|
517
518
|
"UniqueReport": data.unique_report,
|
|
518
519
|
"Lenses": data.lenses,
|
|
520
|
+
"BestPracticeRiskExposure": data.best_practice_risk_exposure,
|
|
519
521
|
}
|
|
520
522
|
|
|
521
523
|
# Make the POST request to generate the report
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"""Bot service client for MontyCloud Day2 SDK."""
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Optional, Union
|
|
4
|
+
|
|
5
|
+
from day2.client.base import BaseClient
|
|
6
|
+
from day2.models.bot import (
|
|
7
|
+
ListComplianceBotFindingsOutput,
|
|
8
|
+
ListComplianceBotPolicyGroupsOutput,
|
|
9
|
+
ListComplianceBotResourceTypesOutput,
|
|
10
|
+
)
|
|
11
|
+
from day2.session import Session
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BotClient(BaseClient):
|
|
15
|
+
"""Client for interacting with the Bot service."""
|
|
16
|
+
|
|
17
|
+
def __init__(self, session: Session) -> None:
|
|
18
|
+
"""Initialize a new BotClient.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
session: MontyCloud session.
|
|
22
|
+
"""
|
|
23
|
+
super().__init__(session, "bot")
|
|
24
|
+
|
|
25
|
+
def list_compliance_bot_findings(
|
|
26
|
+
self,
|
|
27
|
+
tenant_id: str,
|
|
28
|
+
status: Optional[str] = None,
|
|
29
|
+
account_number: Optional[str] = None,
|
|
30
|
+
region_code: Optional[str] = None,
|
|
31
|
+
policy_group: Optional[str] = None,
|
|
32
|
+
resource_type: Optional[str] = None,
|
|
33
|
+
resource_id: Optional[str] = None,
|
|
34
|
+
page_size: int = 10,
|
|
35
|
+
page_number: int = 1,
|
|
36
|
+
) -> ListComplianceBotFindingsOutput:
|
|
37
|
+
"""List compliance bot findings for a tenant.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
tenant_id: ID of the tenant to list findings for.
|
|
41
|
+
status: Compliance type to filter findings by ("Compliant", "Non-Compliant").
|
|
42
|
+
account_number: AWS account number to filter findings by.
|
|
43
|
+
region_code: AWS region code to filter findings by.
|
|
44
|
+
policy_group: Policy group to filter findings by. Allowed values are those returned by the `list_compliance_bot_policy_groups` method.
|
|
45
|
+
resource_type: Resource type to filter findings by. Allowed values are those returned by the `list_compliance_bot_resource_types` method.
|
|
46
|
+
resource_id: Resource ID to filter findings by.
|
|
47
|
+
page_size: Number of findings per page (default: 10, valid range: 1-100).
|
|
48
|
+
page_number: Page number to fetch (default: 1).
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
ListComplianceBotFindingsOutput: Contains findings and pagination information.
|
|
52
|
+
|
|
53
|
+
Raises:
|
|
54
|
+
ResourceNotFoundError: If the tenant does not exist.
|
|
55
|
+
ClientError: If the request is invalid.
|
|
56
|
+
ServerError: If an internal server error occurs.
|
|
57
|
+
AuthenticationError: If authentication fails.
|
|
58
|
+
|
|
59
|
+
Examples:
|
|
60
|
+
>>> session = Session(api_key="your-api-key", api_secret_key="your-secret-key")
|
|
61
|
+
>>> client = session.bot
|
|
62
|
+
>>> response = client.list_compliance_bot_findings(
|
|
63
|
+
... tenant_id="tenant-123",
|
|
64
|
+
... status="Non-Compliant",
|
|
65
|
+
... account_number="123456789012",
|
|
66
|
+
... region_code="us-east-1",
|
|
67
|
+
... policy_group="Security",
|
|
68
|
+
... resource_type="S3",
|
|
69
|
+
... resource_id="bucket-123",
|
|
70
|
+
... page_size=10,
|
|
71
|
+
... page_number=1
|
|
72
|
+
... )
|
|
73
|
+
>>> for finding in response.findings:
|
|
74
|
+
... print(f"{finding.id}: {finding.compliance_type} - {finding.resource_type}")
|
|
75
|
+
|
|
76
|
+
"""
|
|
77
|
+
params: Dict[str, Union[str, int]] = {
|
|
78
|
+
"PageSize": str(page_size),
|
|
79
|
+
"PageNumber": str(page_number),
|
|
80
|
+
}
|
|
81
|
+
if status:
|
|
82
|
+
params["Status"] = status
|
|
83
|
+
if account_number:
|
|
84
|
+
params["AccountNumber"] = account_number
|
|
85
|
+
if region_code:
|
|
86
|
+
params["RegionCode"] = region_code
|
|
87
|
+
if policy_group:
|
|
88
|
+
params["PolicyGroup"] = policy_group
|
|
89
|
+
if resource_type:
|
|
90
|
+
params["ResourceType"] = resource_type
|
|
91
|
+
if resource_id:
|
|
92
|
+
params["ResourceId"] = resource_id
|
|
93
|
+
|
|
94
|
+
response = self._make_request(
|
|
95
|
+
"GET",
|
|
96
|
+
f"tenants/{tenant_id}/bots/compliance/findings",
|
|
97
|
+
params=params,
|
|
98
|
+
)
|
|
99
|
+
return ListComplianceBotFindingsOutput.model_validate(response)
|
|
100
|
+
|
|
101
|
+
def list_compliance_bot_resource_types(
|
|
102
|
+
self,
|
|
103
|
+
tenant_id: str,
|
|
104
|
+
) -> ListComplianceBotResourceTypesOutput:
|
|
105
|
+
"""List supported resource types for the compliance bot findings in a tenant.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
tenant_id: ID of the tenant to list resource types for.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
ListComplianceBotResourceTypesOutput: Contains the list of supported compliance bot resource types.
|
|
112
|
+
|
|
113
|
+
Raises:
|
|
114
|
+
ResourceNotFoundError: If the tenant does not exist.
|
|
115
|
+
ClientError: If the request is invalid.
|
|
116
|
+
ServerError: If an internal server error occurs.
|
|
117
|
+
AuthenticationError: If authentication fails.
|
|
118
|
+
|
|
119
|
+
Examples:
|
|
120
|
+
>>> session = Session(api_key="your-api-key", api_secret_key="your-secret-key")
|
|
121
|
+
>>> client = session.bot
|
|
122
|
+
>>> response = client.list_compliance_bot_resource_types(tenant_id="tenant-123")
|
|
123
|
+
>>> for resource_type in response.resource_types:
|
|
124
|
+
... print(f"{resource_type.resource_type}: {resource_type.label}")
|
|
125
|
+
|
|
126
|
+
"""
|
|
127
|
+
response = self._make_request(
|
|
128
|
+
"GET",
|
|
129
|
+
f"tenants/{tenant_id}/bots/compliance/resource-types",
|
|
130
|
+
)
|
|
131
|
+
return ListComplianceBotResourceTypesOutput.model_validate(response)
|
|
132
|
+
|
|
133
|
+
def list_compliance_bot_policy_groups(
|
|
134
|
+
self,
|
|
135
|
+
tenant_id: str,
|
|
136
|
+
) -> ListComplianceBotPolicyGroupsOutput:
|
|
137
|
+
"""List policy groups for the compliance bot findings in a tenant.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
tenant_id: ID of the tenant to get policy groups for.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
ListComplianceBotPolicyGroupsOutput: Contains the list of policy group names.
|
|
144
|
+
|
|
145
|
+
Raises:
|
|
146
|
+
ResourceNotFoundError: If the tenant does not exist.
|
|
147
|
+
ClientError: If the request is invalid.
|
|
148
|
+
ServerError: If an internal server error occurs.
|
|
149
|
+
AuthenticationError: If authentication fails.
|
|
150
|
+
|
|
151
|
+
Examples:
|
|
152
|
+
>>> session = Session(api_key="your-api-key", api_secret_key="your-secret-key")
|
|
153
|
+
>>> client = session.bot
|
|
154
|
+
>>> response = client.list_compliance_bot_policy_groups(tenant_id="tenant-123")
|
|
155
|
+
>>> for group in response.policy_groups:
|
|
156
|
+
... print(group)
|
|
157
|
+
|
|
158
|
+
"""
|
|
159
|
+
response = self._make_request(
|
|
160
|
+
"GET",
|
|
161
|
+
f"tenants/{tenant_id}/bots/compliance/policy-groups",
|
|
162
|
+
)
|
|
163
|
+
return ListComplianceBotPolicyGroupsOutput.model_validate(response)
|