Skip to content

Commit

Permalink
remove dependant resources
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Oct 17, 2023
1 parent 3b1b1a8 commit d266685
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 656 deletions.
44 changes: 44 additions & 0 deletions plugins/azure/resoto_plugin_azure/resource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
from concurrent.futures import Future
from datetime import datetime
from threading import Lock
from typing import Any, ClassVar, Dict, Optional, TypeVar, List, Type, Callable, cast

Expand Down Expand Up @@ -297,12 +298,55 @@ def list_subscriptions(cls, credentials: AzureCredentials) -> List[AzureSubscrip
return [cls.from_api(js) for js in client.list(cls.api_spec)]


@define(eq=False, slots=False)
class AzureSubResource:
kind: ClassVar[str] = "azure_sub_resource"
mapping: ClassVar[Dict[str, Bender]] = {"id": S("id")}
id: Optional[str] = field(default=None, metadata={"description": "Resource id."})


@define(eq=False, slots=False)
class AzureChildResource:
kind: ClassVar[str] = "azure_child_resource"
mapping: ClassVar[Dict[str, Bender]] = {"etag": S("etag"), "id": S("id"), "name": S("name"), "type": S("type")}
etag: Optional[str] = field(default=None, metadata={'description': 'A unique read-only string that changes whenever the resource is updated.'}) # fmt: skip
type: Optional[str] = field(default=None, metadata={"description": "Resource type."})


@define(eq=False, slots=False)
class AzureSystemData:
kind: ClassVar[str] = "azure_system_data"
mapping: ClassVar[Dict[str, Bender]] = {
"created_at": S("createdAt"),
"created_by": S("createdBy"),
"created_by_type": S("createdByType"),
"last_modified_at": S("lastModifiedAt"),
"last_modified_by": S("lastModifiedBy"),
"last_modified_by_type": S("lastModifiedByType"),
}
created_at: Optional[datetime] = field(default=None, metadata={'description': 'The timestamp of resource creation (utc).'}) # fmt: skip
created_by: Optional[str] = field(default=None, metadata={'description': 'The identity that created the resource.'}) # fmt: skip
created_by_type: Optional[str] = field(default=None, metadata={'description': 'The type of identity that created the resource.'}) # fmt: skip
last_modified_at: Optional[datetime] = field(default=None, metadata={'description': 'The type of identity that last modified the resource.'}) # fmt: skip
last_modified_by: Optional[str] = field(default=None, metadata={'description': 'The identity that last modified the resource.'}) # fmt: skip
last_modified_by_type: Optional[str] = field(default=None, metadata={'description': 'The type of identity that last modified the resource.'}) # fmt: skip


@define(eq=False, slots=False)
class AzureSku:
kind: ClassVar[str] = "azure_sku"
mapping: ClassVar[Dict[str, Bender]] = {
"capacity": S("capacity"),
"name": S("name"),
"tier": S("tier"),
"family": S("family"),
}
capacity: Optional[int] = field(default=None, metadata={'description': 'Specifies the number of virtual machines in the scale set.'}) # fmt: skip
family: Optional[str] = field(default=None, metadata={"description": "The family of the sku."})
name: Optional[str] = field(default=None, metadata={"description": "The sku name."})
tier: Optional[str] = field(default=None, metadata={'description': 'Specifies the tier of virtual machines in a scale set. Possible values: **standard** **basic**.'}) # fmt: skip


class GraphBuilder:
def __init__(
self,
Expand Down
19 changes: 1 addition & 18 deletions plugins/azure/resoto_plugin_azure/resource/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from attr import define, field

from resoto_plugin_azure.azure_client import AzureApiSpec
from resoto_plugin_azure.resource.base import AzureResource, GraphBuilder, AzureSubResource
from resoto_plugin_azure.resource.base import AzureResource, GraphBuilder, AzureSubResource, AzureSystemData, AzureSku
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 @@ -37,15 +37,6 @@ class AzureInstanceViewStatus:
time: Optional[datetime] = field(default=None, metadata={"description": "The time of the status."})


@define(eq=False, slots=False)
class AzureSku:
kind: ClassVar[str] = "azure_sku"
mapping: ClassVar[Dict[str, Bender]] = {"capacity": S("capacity"), "name": S("name"), "tier": S("tier")}
capacity: Optional[int] = field(default=None, metadata={'description': 'Specifies the number of virtual machines in the scale set.'}) # fmt: skip
name: Optional[str] = field(default=None, metadata={"description": "The sku name."})
tier: Optional[str] = field(default=None, metadata={'description': 'Specifies the tier of virtual machines in a scale set. Possible values: **standard** **basic**.'}) # fmt: skip


@define(eq=False, slots=False)
class AzureAvailabilitySet(AzureResource):
kind: ClassVar[str] = "azure_availability_set"
Expand Down Expand Up @@ -277,14 +268,6 @@ class AzureCloudServiceExtensionProfile:
extensions: Optional[List[AzureExtension]] = field(default=None, metadata={'description': 'List of extensions for the cloud service.'}) # fmt: skip


@define(eq=False, slots=False)
class AzureSystemData:
kind: ClassVar[str] = "azure_system_data"
mapping: ClassVar[Dict[str, Bender]] = {"created_at": S("createdAt"), "last_modified_at": S("lastModifiedAt")}
created_at: Optional[datetime] = field(default=None, metadata={'description': 'Specifies the time in utc at which the cloud service (extended support) resource was created. Minimum api-version: 2022-04-04.'}) # fmt: skip
last_modified_at: Optional[datetime] = field(default=None, metadata={'description': 'Specifies the time in utc at which the cloud service (extended support) resource was last modified. Minimum api-version: 2022-04-04.'}) # fmt: skip


@define(eq=False, slots=False)
class AzureCloudService(AzureResource):
kind: ClassVar[str] = "azure_cloud_service"
Expand Down
Loading

0 comments on commit d266685

Please sign in to comment.