Skip to content

Commit 303e661

Browse files
authored
[azure][fix] Define Phantom Resources (#2230)
1 parent 8482aa6 commit 303e661

File tree

9 files changed

+28
-21
lines changed

9 files changed

+28
-21
lines changed

plugins/azure/fix_plugin_azure/resource/authorization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
MicrosoftGraphGroup,
1919
MicrosoftGraphPrincipalTypes,
2020
)
21-
from fixlib.baseresources import BaseRole, ModelReference
21+
from fixlib.baseresources import BaseRole, ModelReference, PhantomBaseResource
2222
from fixlib.graph import BySearchCriteria
2323
from fixlib.json_bender import Bender, S, ForallBend, Bend
2424
from fixlib.types import Json
@@ -227,7 +227,7 @@ class AzurePermission:
227227

228228

229229
@define(eq=False, slots=False)
230-
class AzureAuthorizationRoleDefinition(MicrosoftResource, BaseRole):
230+
class AzureAuthorizationRoleDefinition(MicrosoftResource, BaseRole, PhantomBaseResource):
231231
kind: ClassVar[str] = "azure_authorization_role_definition"
232232
_kind_display: ClassVar[str] = "Azure Authorization Role Definition"
233233
_kind_service: ClassVar[Optional[str]] = service_name

plugins/azure/fix_plugin_azure/resource/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,11 @@ class AzureUsageName:
478478

479479

480480
@define(eq=False, slots=False)
481-
class AzureBaseUsage:
481+
class AzureBaseUsage(PhantomBaseResource):
482482
kind: ClassVar[str] = "azure_usage"
483+
_kind_display: ClassVar[str] = "Azure Usage"
484+
_kind_service: ClassVar[Optional[str]] = "resources"
485+
_kind_description: ClassVar[str] = "Azure Usage represents the usage of a resource in an Azure subscription. It provides information about the current value of the usage, the limit of usage, and the unit of measurement. Azure Usage is used to track resource consumption and enforce usage limits, helping users manage costs and optimize resource utilization." # fmt: skip
483486
mapping: ClassVar[Dict[str, Bender]] = {
484487
"name": S("name", "value"), # inherited by BaseResource - name already defined there
485488
"usage_name": S("name") >> Bend(AzureUsageName.mapping),

plugins/azure/fix_plugin_azure/resource/cosmosdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from fix_plugin_azure.resource.mysql import AzureServerDataEncryption
2424
from fix_plugin_azure.resource.network import AzureNetworkSubnet
2525
from fix_plugin_azure.utils import from_str_to_typed
26-
from fixlib.baseresources import BaseDatabase, DatabaseInstanceStatus, EdgeType, ModelReference
26+
from fixlib.baseresources import BaseDatabase, DatabaseInstanceStatus, EdgeType, ModelReference, PhantomBaseResource
2727
from fixlib.graph import BySearchCriteria
2828
from fixlib.json_bender import F, K, Bender, S, ForallBend, Bend, MapEnum, MapValue
2929
from fixlib.types import Json
@@ -2042,7 +2042,7 @@ def collect_usages(cls, account_id: str, raw: List[Json], builder: GraphBuilder)
20422042

20432043

20442044
@define(eq=False, slots=False)
2045-
class AzureCosmosDBLocation(CosmosDBLocationSetter, MicrosoftResource):
2045+
class AzureCosmosDBLocation(CosmosDBLocationSetter, MicrosoftResource, PhantomBaseResource):
20462046
kind: ClassVar[str] = "azure_cosmos_db_location"
20472047
_kind_display: ClassVar[str] = "Azure Cosmos DB Location"
20482048
_kind_service: ClassVar[Optional[str]] = service_name

plugins/azure/fix_plugin_azure/resource/machinelearning.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from fix_plugin_azure.resource.network import AzureNetworkSubnet, AzureNetworkVirtualNetwork
2626
from fix_plugin_azure.resource.storage import AzureStorageAccount
2727
from fix_plugin_azure.resource.web import AzureWebApp
28-
from fixlib.baseresources import BaseInstanceType, ModelReference, BaseAIJob, BaseAIModel
28+
from fixlib.baseresources import BaseInstanceType, ModelReference, BaseAIJob, BaseAIModel, PhantomBaseResource
2929
from fixlib.graph import BySearchCriteria
3030
from fixlib.json_bender import Bender, S, ForallBend, Bend, K
3131
from fixlib.types import Json
@@ -1005,7 +1005,7 @@ def collect_versions() -> None:
10051005

10061006

10071007
@define(eq=False, slots=False)
1008-
class AzureMachineLearningEnvironmentVersionBase(CheckVersionIsArchived, AzureProxyResource):
1008+
class AzureMachineLearningEnvironmentVersionBase(CheckVersionIsArchived, AzureProxyResource, PhantomBaseResource):
10091009
kind: ClassVar[str] = "azure_machine_learning_environment_version_base"
10101010
_kind_display: ClassVar[str] = "Azure Machine Learning Environment Version Base"
10111011
_kind_service: ClassVar[Optional[str]] = service_name
@@ -2224,7 +2224,7 @@ def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
22242224

22252225

22262226
@define(eq=False, slots=False)
2227-
class AzureMachineLearningQuota(MicrosoftResource):
2227+
class AzureMachineLearningQuota(MicrosoftResource, PhantomBaseResource):
22282228
kind: ClassVar[str] = "azure_machine_learning_quota"
22292229
_kind_display: ClassVar[str] = "Azure Machine Learning Quota"
22302230
_kind_service: ClassVar[Optional[str]] = service_name

plugins/azure/fix_plugin_azure/resource/network.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
BaseTunnel,
3838
ModelReference,
3939
EdgeType,
40+
PhantomBaseResource,
4041
)
4142
from fixlib.json_bender import F, Bender, S, Bend, ForallBend, AsInt, StringToUnitNumber, Upper, Lower
4243
from fixlib.types import Json
@@ -1119,7 +1120,7 @@ class AzureApplicationGatewayFirewallRuleGroup:
11191120

11201121

11211122
@define(eq=False, slots=False)
1122-
class AzureNetworkApplicationGatewayFirewallRuleSet(MicrosoftResource):
1123+
class AzureNetworkApplicationGatewayFirewallRuleSet(MicrosoftResource, PhantomBaseResource):
11231124
kind: ClassVar[str] = "azure_network_application_gateway_firewall_rule_set"
11241125
_kind_display: ClassVar[str] = "Azure Network Application Gateway Firewall Rule Set"
11251126
_kind_service: ClassVar[Optional[str]] = service_name
@@ -3465,7 +3466,7 @@ class AzureExpressRoutePortsLocationBandwidths:
34653466

34663467

34673468
@define(eq=False, slots=False)
3468-
class AzureNetworkExpressRoutePortsLocation(MicrosoftResource):
3469+
class AzureNetworkExpressRoutePortsLocation(MicrosoftResource, PhantomBaseResource):
34693470
kind: ClassVar[str] = "azure_network_express_route_ports_location"
34703471
_kind_display: ClassVar[str] = "Azure Network Express Route Ports Location"
34713472
_kind_service: ClassVar[Optional[str]] = service_name
@@ -4530,7 +4531,7 @@ class AzureNetworkVirtualApplianceSkuInstances:
45304531

45314532

45324533
@define(eq=False, slots=False)
4533-
class AzureNetworkVirtualApplianceSku(MicrosoftResource):
4534+
class AzureNetworkVirtualApplianceSku(MicrosoftResource, PhantomBaseResource):
45344535
kind: ClassVar[str] = "azure_network_virtual_appliance_sku"
45354536
_kind_display: ClassVar[str] = "Azure Network Virtual Appliance SKU"
45364537
_kind_service: ClassVar[Optional[str]] = service_name
@@ -4877,7 +4878,7 @@ class AzureNetworkRouteFilter(MicrosoftResource):
48774878

48784879

48794880
@define(eq=False, slots=False)
4880-
class AzureNetworkSecurityPartnerProvider(MicrosoftResource):
4881+
class AzureNetworkSecurityPartnerProvider(MicrosoftResource, PhantomBaseResource):
48814882
kind: ClassVar[str] = "azure_network_security_partner_provider"
48824883
_kind_display: ClassVar[str] = "Azure Network Security Partner Provider"
48834884
_kind_service: ClassVar[Optional[str]] = service_name

plugins/azure/fix_plugin_azure/resource/security.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from fix_plugin_azure.azure_client import AzureResourceSpec
77
from fix_plugin_azure.resource.base import MicrosoftResource, AzureSystemData, GraphBuilder
8-
from fixlib.baseresources import ModelReference
8+
from fixlib.baseresources import ModelReference, PhantomBaseResource
99
from fixlib.json_bender import Bender, S, Bend, ForallBend, F
1010
from fixlib.types import Json
1111

@@ -36,7 +36,7 @@ class AzureSecurityExtension:
3636

3737

3838
@define(eq=False, slots=False)
39-
class AzureSecurityPricing(MicrosoftResource):
39+
class AzureSecurityPricing(MicrosoftResource, PhantomBaseResource):
4040
kind: ClassVar[str] = "azure_security_pricing"
4141
_kind_display: ClassVar[str] = "Azure Security Pricing"
4242
_kind_service: ClassVar[Optional[str]] = service_name
@@ -92,7 +92,7 @@ class AzureAssessmentStatus:
9292

9393

9494
@define(eq=False, slots=False)
95-
class AzureSecurityAssessment(MicrosoftResource):
95+
class AzureSecurityAssessment(MicrosoftResource, PhantomBaseResource):
9696
kind: ClassVar[str] = "azure_security_assessment"
9797
_kind_display: ClassVar[str] = "Azure Security Assessment"
9898
_kind_service: ClassVar[Optional[str]] = service_name

plugins/azure/fix_plugin_azure/resource/storage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
MetricName,
2626
MetricUnit,
2727
ModelReference,
28+
PhantomBaseResource,
2829
)
2930
from fixlib.json_bender import Bender, S, ForallBend, Bend
3031
from fixlib.types import Json
@@ -188,7 +189,7 @@ class AzureStorageBlobContainer(MicrosoftResource, BaseBucket):
188189

189190

190191
@define(eq=False, slots=False)
191-
class AzureStorageAccountDeleted(MicrosoftResource):
192+
class AzureStorageAccountDeleted(MicrosoftResource, PhantomBaseResource):
192193
kind: ClassVar[str] = "azure_storage_account_deleted"
193194
_kind_display: ClassVar[str] = "Azure Storage Account Deleted"
194195
_kind_service: ClassVar[Optional[str]] = service_name
@@ -340,7 +341,7 @@ class AzureRestriction:
340341

341342

342343
@define(eq=False, slots=False)
343-
class AzureStorageSku(MicrosoftResource):
344+
class AzureStorageSku(MicrosoftResource, PhantomBaseResource):
344345
kind: ClassVar[str] = "azure_storage_sku"
345346
_kind_display: ClassVar[str] = "Azure Storage SKU"
346347
_kind_service: ClassVar[Optional[str]] = service_name

plugins/azure/test/collector_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def collector_with_graph(
3131
account=AzureSubscription(id="test", subscription_id="test"),
3232
credentials=credentials,
3333
core_feedback=CoreFeedback("test", "test", "test", Queue()),
34+
filter_unused_resources=False,
3435
)
3536
collector.graph = graph
3637
return collector
@@ -44,11 +45,11 @@ def test_collect(
4445
azure_client: MicrosoftClient,
4546
) -> None:
4647
subscription_collector = AzureSubscriptionCollector(
47-
config, Cloud(id="azure"), azure_subscription, credentials, core_feedback
48+
config, Cloud(id="azure"), azure_subscription, credentials, core_feedback, filter_unused_resources=False
4849
)
4950
subscription_collector.collect()
50-
assert len(subscription_collector.graph.nodes) == 588
51-
assert len(subscription_collector.graph.edges) == 977
51+
assert len(subscription_collector.graph.nodes) == 952
52+
assert len(subscription_collector.graph.edges) == 1341
5253

5354
graph_collector = MicrosoftGraphOrganizationCollector(
5455
config, Cloud(id="azure"), MicrosoftGraphOrganization(id="test", name="test"), credentials, core_feedback

plugins/gcp/fix_plugin_gcp/resources/compute.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
VolumeStatus,
3030
BaseInstance,
3131
InstanceStatus,
32+
PhantomBaseResource,
3233
)
3334
from fixlib.json_bender import Bender, S, Bend, ForallBend, MapDict, F, MapEnum, AsInt
3435
from fixlib.types import Json
@@ -3705,7 +3706,7 @@ class GcpInterconnectLocationRegionInfo:
37053706

37063707

37073708
@define(eq=False, slots=False)
3708-
class GcpInterconnectLocation(GcpResource):
3709+
class GcpInterconnectLocation(GcpResource, PhantomBaseResource):
37093710
kind: ClassVar[str] = "gcp_interconnect_location"
37103711
_kind_display: ClassVar[str] = "GCP Interconnect Location"
37113712
_kind_description: ClassVar[str] = "A GCP Interconnect Location is a physical facility where Google Cloud Platform connects to external networks. It serves as a point of presence for establishing direct, private network connections between an organization's on-premises infrastructure and Google's network. This connection reduces latency, enhances security, and improves data transfer performance compared to public internet connections." # fmt: skip

0 commit comments

Comments
 (0)