Skip to content

Commit

Permalink
feat: added comment why fetching of resources data failed
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Nov 4, 2024
1 parent 035b5de commit ea61d7f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions plugins/azure/fix_plugin_azure/resource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def parse_json(
return None


LACK_OF_READ_PERMISSION = "Error: Insufficient permissions to access the requested resource. Please ensure that the necessary read permissions are granted to your account or service principal."


@define(eq=False, slots=False)
class MicrosoftResource(BaseResource):
kind: ClassVar[str] = "microsoft_resource"
Expand Down
3 changes: 2 additions & 1 deletion plugins/azure/fix_plugin_azure/resource/cosmosdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from fix_plugin_azure.azure_client import AzureResourceSpec
from fix_plugin_azure.resource.base import (
LACK_OF_READ_PERMISSION,
AzureBaseUsage,
AzurePrivateLinkServiceConnectionState,
AzureProxyResource,
Expand Down Expand Up @@ -2057,7 +2058,7 @@ class AzureCosmosDBLocation(CosmosDBLocationSetter, MicrosoftResource, PhantomBa
query_parameters=["api-version"],
access_path="value",
expect_array=True,
expected_error_codes={"Internal Server Error": None},
expected_error_codes={"Internal Server Error": LACK_OF_READ_PERMISSION},
)
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("id"),
Expand Down
3 changes: 2 additions & 1 deletion plugins/azure/fix_plugin_azure/resource/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from fix_plugin_azure.azure_client import AzureResourceSpec
from fix_plugin_azure.resource.base import (
LACK_OF_READ_PERMISSION,
AzureBaseUsage,
GraphBuilder,
AzureSubResource,
Expand Down Expand Up @@ -6771,7 +6772,7 @@ class AzureNetworkDNSZone(MicrosoftResource, BaseDNSZone):
query_parameters=["api-version"],
access_path="value",
expect_array=True,
expected_error_codes={"BadRequest": None},
expected_error_codes={"BadRequest": LACK_OF_READ_PERMISSION},
)
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("id"),
Expand Down
5 changes: 3 additions & 2 deletions plugins/azure/fix_plugin_azure/resource/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from fix_plugin_azure.azure_client import AzureResourceSpec
from fix_plugin_azure.resource.base import (
LACK_OF_READ_PERMISSION,
AzureBaseUsage,
MicrosoftResource,
MicrosoftResourceType,
Expand Down Expand Up @@ -204,7 +205,7 @@ class AzureStorageAccountDeleted(MicrosoftResource, PhantomBaseResource):
query_parameters=["api-version"],
access_path="value",
expect_array=True,
expected_error_codes={"ProviderError": None},
expected_error_codes={"ProviderError": LACK_OF_READ_PERMISSION},
)
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("id"),
Expand Down Expand Up @@ -1083,7 +1084,7 @@ class AzureStorageAccountUsage(MicrosoftResource, AzureBaseUsage):
query_parameters=["api-version"],
access_path="value",
expect_array=True,
expected_error_codes=AzureBaseUsage._expected_error_codes | {"SubscriptionNotFound": None},
expected_error_codes=AzureBaseUsage._expected_error_codes | {"SubscriptionNotFound": LACK_OF_READ_PERMISSION},
)
mapping: ClassVar[Dict[str, Bender]] = AzureBaseUsage.mapping | {
"id": S("name", "value"),
Expand Down

0 comments on commit ea61d7f

Please sign in to comment.