Skip to content

Commit

Permalink
fix: Moved some classes to base (#1822)
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Nov 16, 2023
1 parent 25d2be1 commit a7a44e7
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 68 deletions.
29 changes: 29 additions & 0 deletions plugins/azure/resoto_plugin_azure/resource/base.py
Expand Up @@ -274,6 +274,35 @@ def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureResource, id=resource_id)


@define(eq=False, slots=False)
class AzureExtendedLocation:
kind: ClassVar[str] = "azure_extended_location"
mapping: ClassVar[Dict[str, Bender]] = {"name": S("name"), "type": S("type")}
name: Optional[str] = field(default=None, metadata={"description": "The name of the extended location."})
type: Optional[str] = field(default=None, metadata={"description": "The type of extendedlocation."})


@define(eq=False, slots=False)
class AzurePrincipalidClientid:
kind: ClassVar[str] = "azure_principalid_clientid"
mapping: ClassVar[Dict[str, Bender]] = {"client_id": S("clientId"), "principal_id": S("principalId")}
client_id: Optional[str] = field(default=None, metadata={'description': 'The client id of user assigned identity.'}) # fmt: skip
principal_id: Optional[str] = field(default=None, metadata={'description': 'The principal id of user assigned identity.'}) # fmt: skip


@define(eq=False, slots=False)
class AzurePrivateLinkServiceConnectionState:
kind: ClassVar[str] = "azure_private_link_service_connection_state"
mapping: ClassVar[Dict[str, Bender]] = {
"actions_required": S("actionsRequired"),
"description": S("description"),
"status": S("status"),
}
actions_required: Optional[str] = field(default=None, metadata={'description': 'A message indicating if changes on the service provider require any updates on the consumer.'}) # fmt: skip
description: Optional[str] = field(default=None, metadata={'description': 'The reason for approval/rejection of the connection.'}) # fmt: skip
status: Optional[str] = field(default=None, metadata={"description": "The private endpoint connection status."})


@define(eq=False, slots=False)
class AzureSubscriptionPolicies:
kind: ClassVar[str] = "azure_subscription_policies"
Expand Down
48 changes: 14 additions & 34 deletions plugins/azure/resoto_plugin_azure/resource/compute.py
Expand Up @@ -4,7 +4,16 @@
from attr import define, field

from resoto_plugin_azure.azure_client import AzureApiSpec
from resoto_plugin_azure.resource.base import AzureResource, GraphBuilder, AzureSubResource, AzureSystemData, AzureSku
from resoto_plugin_azure.resource.base import (
AzureResource,
GraphBuilder,
AzureSubResource,
AzureSystemData,
AzureSku,
AzureExtendedLocation,
AzurePrincipalidClientid,
AzurePrivateLinkServiceConnectionState,
)
from resotolib.json_bender import Bender, S, Bend, MapEnum, ForallBend, K, F
from resotolib.types import Json
from resotolib.baseresources import (
Expand Down Expand Up @@ -458,14 +467,6 @@ class AzureDiskSku:
tier: Optional[str] = field(default=None, metadata={"description": "The sku tier."})


@define(eq=False, slots=False)
class AzureExtendedLocation:
kind: ClassVar[str] = "azure_extended_location"
mapping: ClassVar[Dict[str, Bender]] = {"name": S("name"), "type": S("type")}
name: Optional[str] = field(default=None, metadata={"description": "The name of the extended location."})
type: Optional[str] = field(default=None, metadata={"description": "The type of extendedlocation."})


@define(eq=False, slots=False)
class AzurePurchasePlan:
kind: ClassVar[str] = "azure_purchase_plan"
Expand Down Expand Up @@ -719,21 +720,8 @@ def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:


@define(eq=False, slots=False)
class AzurePrivateLinkServiceConnectionState:
kind: ClassVar[str] = "azure_private_link_service_connection_state"
mapping: ClassVar[Dict[str, Bender]] = {
"actions_required": S("actionsRequired"),
"description": S("description"),
"status": S("status"),
}
actions_required: Optional[str] = field(default=None, metadata={'description': 'A message indicating if changes on the service provider require any updates on the consumer.'}) # fmt: skip
description: Optional[str] = field(default=None, metadata={'description': 'The reason for approval/rejection of the connection.'}) # fmt: skip
status: Optional[str] = field(default=None, metadata={"description": "The private endpoint connection status."})


@define(eq=False, slots=False)
class AzurePrivateEndpointConnection:
kind: ClassVar[str] = "azure_private_endpoint_connection"
class AzureDiskAccessPrivateEndpointConnection:
kind: ClassVar[str] = "azure_disk_access_private_endpoint_connection"
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("id"),
"name": S("name"),
Expand Down Expand Up @@ -772,24 +760,16 @@ class AzureDiskAccess(AzureResource):
"atime": K(None),
"extended_location": S("extendedLocation") >> Bend(AzureExtendedLocation.mapping),
"private_endpoint_connections": S("properties", "privateEndpointConnections")
>> ForallBend(AzurePrivateEndpointConnection.mapping),
>> ForallBend(AzureDiskAccessPrivateEndpointConnection.mapping),
"provisioning_state": S("properties", "provisioningState"),
"time_created": S("properties", "timeCreated"),
}
extended_location: Optional[AzureExtendedLocation] = field(default=None, metadata={'description': 'The complex type of the extended location.'}) # fmt: skip
private_endpoint_connections: Optional[List[AzurePrivateEndpointConnection]] = field(default=None, metadata={'description': 'A readonly collection of private endpoint connections created on the disk. Currently only one endpoint connection is supported.'}) # fmt: skip
private_endpoint_connections: Optional[List[AzureDiskAccessPrivateEndpointConnection]] = field(default=None, metadata={'description': 'A readonly collection of private endpoint connections created on the disk. Currently only one endpoint connection is supported.'}) # fmt: skip
provisioning_state: Optional[str] = field(default=None, metadata={'description': 'The disk access resource provisioning state.'}) # fmt: skip
time_created: Optional[datetime] = field(default=None, metadata={'description': 'The time when the disk access was created.'}) # fmt: skip


@define(eq=False, slots=False)
class AzurePrincipalidClientid:
kind: ClassVar[str] = "azure_principalid_clientid"
mapping: ClassVar[Dict[str, Bender]] = {"client_id": S("clientId"), "principal_id": S("principalId")}
client_id: Optional[str] = field(default=None, metadata={'description': 'The client id of user assigned identity.'}) # fmt: skip
principal_id: Optional[str] = field(default=None, metadata={'description': 'The principal id of user assigned identity.'}) # fmt: skip


@define(eq=False, slots=False)
class AzureEncryptionSetIdentity:
kind: ClassVar[str] = "azure_encryption_set_identity"
Expand Down
46 changes: 12 additions & 34 deletions plugins/azure/resoto_plugin_azure/resource/network.py
Expand Up @@ -3,7 +3,14 @@
from attr import define, field

from resoto_plugin_azure.azure_client import AzureApiSpec
from resoto_plugin_azure.resource.base import AzureResource, AzureSubResource, AzureSku
from resoto_plugin_azure.resource.base import (
AzureResource,
AzureSubResource,
AzureSku,
AzureExtendedLocation,
AzurePrincipalidClientid,
AzurePrivateLinkServiceConnectionState,
)
from resotolib.json_bender import Bender, S, Bend, ForallBend, K, AsInt, StringToUnitNumber


Expand Down Expand Up @@ -753,27 +760,6 @@ class AzureApplicationGatewayPrivateLinkConfiguration(AzureSubResource):
type: Optional[str] = field(default=None, metadata={"description": "Type of the resource."})


@define(eq=False, slots=False)
class AzureExtendedLocation:
kind: ClassVar[str] = "azure_extended_location"
mapping: ClassVar[Dict[str, Bender]] = {"name": S("name"), "type": S("type")}
name: Optional[str] = field(default=None, metadata={"description": "The name of the extended location."})
type: Optional[str] = field(default=None, metadata={'description': 'The supported ExtendedLocation types. Currently only EdgeZone is supported in Microsoft.Network resources.'}) # fmt: skip


@define(eq=False, slots=False)
class AzurePrivateLinkServiceConnectionState:
kind: ClassVar[str] = "azure_private_link_service_connection_state"
mapping: ClassVar[Dict[str, Bender]] = {
"actions_required": S("actionsRequired"),
"description": S("description"),
"status": S("status"),
}
actions_required: Optional[str] = field(default=None, metadata={'description': 'A message indicating if changes on the service provider require any updates on the consumer.'}) # fmt: skip
description: Optional[str] = field(default=None, metadata={'description': 'The reason for approval/rejection of the connection.'}) # fmt: skip
status: Optional[str] = field(default=None, metadata={'description': 'Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service.'}) # fmt: skip


@define(eq=False, slots=False)
class AzurePrivateLinkServiceConnection(AzureSubResource):
kind: ClassVar[str] = "azure_private_link_service_connection"
Expand Down Expand Up @@ -958,14 +944,6 @@ class AzureApplicationGatewayGlobalConfiguration:
enable_response_buffering: Optional[bool] = field(default=None, metadata={'description': 'Enable response buffering.'}) # fmt: skip


@define(eq=False, slots=False)
class AzurePrincipalidClientid:
kind: ClassVar[str] = "azure_principalid_clientid"
mapping: ClassVar[Dict[str, Bender]] = {"client_id": S("clientId"), "principal_id": S("principalId")}
client_id: Optional[str] = field(default=None, metadata={'description': 'The client id of user assigned identity.'}) # fmt: skip
principal_id: Optional[str] = field(default=None, metadata={'description': 'The principal id of user assigned identity.'}) # fmt: skip


@define(eq=False, slots=False)
class AzureManagedServiceIdentity:
kind: ClassVar[str] = "azure_managed_service_identity"
Expand Down Expand Up @@ -2487,8 +2465,8 @@ class AzurePrivateLinkServiceIpConfiguration(AzureSubResource):


@define(eq=False, slots=False)
class AzurePrivateEndpointConnection(AzureSubResource):
kind: ClassVar[str] = "azure_private_endpoint_connection"
class AzureLinkServicePrivateEndpointConnection(AzureSubResource):
kind: ClassVar[str] = "azure_link_service_private_endpoint_connection"
mapping: ClassVar[Dict[str, Bender]] = AzureSubResource.mapping | {
"etag": S("etag"),
"link_identifier": S("properties", "linkIdentifier"),
Expand Down Expand Up @@ -2535,7 +2513,7 @@ class AzurePrivateLinkService:
"location": S("location"),
"name": S("name"),
"private_endpoint_connections": S("properties", "privateEndpointConnections")
>> ForallBend(AzurePrivateEndpointConnection.mapping),
>> ForallBend(AzureLinkServicePrivateEndpointConnection.mapping),
"provisioning_state": S("properties", "provisioningState"),
"tags": S("tags"),
"type": S("type"),
Expand All @@ -2552,7 +2530,7 @@ class AzurePrivateLinkService:
load_balancer_frontend_ip_configurations: Optional[List[AzureFrontendIPConfiguration]] = field(default=None, metadata={'description': 'An array of references to the load balancer IP configurations.'}) # fmt: skip
location: Optional[str] = field(default=None, metadata={"description": "Resource location."})
name: Optional[str] = field(default=None, metadata={"description": "Resource name."})
private_endpoint_connections: Optional[List[AzurePrivateEndpointConnection]] = field(default=None, metadata={'description': 'An array of list about connections to the private endpoint.'}) # fmt: skip
private_endpoint_connections: Optional[List[AzureLinkServicePrivateEndpointConnection]] = field(default=None, metadata={'description': 'An array of list about connections to the private endpoint.'}) # fmt: skip
provisioning_state: Optional[str] = field(default=None, metadata={'description': 'The current provisioning state.'}) # fmt: skip
tags: Optional[Dict[str, str]] = field(default=None, metadata={"description": "Resource tags."})
type: Optional[str] = field(default=None, metadata={"description": "Resource type."})
Expand Down

0 comments on commit a7a44e7

Please sign in to comment.