-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
azure - servicebus-namespace-networkruleset (#8546)
- Loading branch information
Showing
5 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
tools/c7n_azure/c7n_azure/resources/servicebus_namespace_networkrules.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
# Copyright The Cloud Custodian Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from c7n_azure.provider import resources | ||
from c7n_azure.query import ChildResourceManager, ChildTypeInfo | ||
from c7n_azure.utils import ResourceIdParser | ||
|
||
|
||
@resources.register('servicebus-namespace-networkrules') | ||
class ServiceBusNamespaceNetworkrules(ChildResourceManager): | ||
|
||
"""Azure Service Bus Namespace Network Ruleset Resource | ||
:example: | ||
Returns Service Bus Namespace Network Ruleset resources | ||
.. code-block:: yaml | ||
policies: | ||
- name: basic-servicebus-namespace-networkrule | ||
resource: azure.servicebus-namespace-networkrules | ||
""" | ||
|
||
class resource_type(ChildTypeInfo): | ||
doc_groups = ['Events'] | ||
|
||
service = 'azure.mgmt.servicebus' | ||
client = 'ServiceBusManagementClient' | ||
enum_spec = ('namespaces', 'list_network_rule_sets', None) | ||
parent_manager_name = 'servicebus-namespace' | ||
default_report_fields = ( | ||
'name', | ||
'location', | ||
'resourceGroup' | ||
) | ||
resource_type = 'Microsoft.ServiceBus/namespaces' | ||
|
||
@classmethod | ||
def extra_args(cls, parent_resource): | ||
return {'resource_group_name': | ||
ResourceIdParser.get_resource_group(parent_resource['id']), | ||
'namespace_name': parent_resource['name']} |
117 changes: 117 additions & 0 deletions
117
...7n_azure/tests_azure/cassettes/ServiceBusNamespaceNetworkrulesTest.test_find_by_name.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
{ | ||
"version": 1, | ||
"interactions": [ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"uri": "https://management.azure.com/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/providers/Microsoft.ServiceBus/namespaces?api-version=2021-11-01", | ||
"body": null, | ||
"headers": {} | ||
}, | ||
"response": { | ||
"status": { | ||
"code": 200, | ||
"message": "OK" | ||
}, | ||
"headers": { | ||
"x-ms-inline-count": [ | ||
"" | ||
], | ||
"cache-control": [ | ||
"no-cache" | ||
], | ||
"date": [ | ||
"Tue, 09 May 2023 16:17:44 GMT" | ||
], | ||
"content-type": [ | ||
"application/json; charset=utf-8" | ||
], | ||
"server-sb": [ | ||
"Service-Bus-Resource-Provider/SN1" | ||
], | ||
"content-length": [ | ||
"667" | ||
] | ||
}, | ||
"body": { | ||
"data": { | ||
"value": [ | ||
{ | ||
"sku": { | ||
"name": "Standard", | ||
"tier": "Standard" | ||
}, | ||
"id": "/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/resourceGroups/cfb-fphecjqp/providers/Microsoft.ServiceBus/namespaces/c7nfail-sbnamespace", | ||
"name": "c7nfail-sbnamespace", | ||
"type": "Microsoft.ServiceBus/Namespaces", | ||
"location": "Central US", | ||
"tags": { | ||
"product_id": "13742" | ||
}, | ||
"properties": { | ||
"disableLocalAuth": false, | ||
"zoneRedundant": false, | ||
"provisioningState": "Succeeded", | ||
"metricId": "ea42f556-5106-4743-99b0-c129bfa71a47:c7nfail-sbnamespace", | ||
"createdAt": "2023-05-09T16:14:32.29Z", | ||
"updatedAt": "2023-05-09T16:15:43.91Z", | ||
"serviceBusEndpoint": "https://c7nfail-sbnamespace.servicebus.windows.net:443/", | ||
"status": "Active" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"uri": "https://management.azure.com/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/resourceGroups/cfb-fphecjqp/providers/Microsoft.ServiceBus/namespaces/c7nfail-sbnamespace/networkRuleSets?api-version=2021-11-01", | ||
"body": null, | ||
"headers": {} | ||
}, | ||
"response": { | ||
"status": { | ||
"code": 200, | ||
"message": "OK" | ||
}, | ||
"headers": { | ||
"cache-control": [ | ||
"no-cache" | ||
], | ||
"date": [ | ||
"Tue, 09 May 2023 16:17:45 GMT" | ||
], | ||
"content-type": [ | ||
"application/json; charset=utf-8" | ||
], | ||
"server-sb": [ | ||
"Service-Bus-Resource-Provider/SN1" | ||
], | ||
"content-length": [ | ||
"393" | ||
] | ||
}, | ||
"body": { | ||
"data": { | ||
"value": [ | ||
{ | ||
"id": "/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/resourceGroups/cfb-fphecjqp/providers/Microsoft.ServiceBus/namespaces/c7nfail-sbnamespace/networkRuleSets/default", | ||
"name": "default", | ||
"type": "Microsoft.ServiceBus/Namespaces/NetworkRuleSets", | ||
"location": "Central US", | ||
"properties": { | ||
"publicNetworkAccess": "Enabled", | ||
"defaultAction": "Allow", | ||
"virtualNetworkRules": [], | ||
"ipRules": [] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
tools/c7n_azure/tests_azure/tests_resources/test_servicebus_namespace_networkrules.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright The Cloud Custodian Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from ..azure_common import BaseTest | ||
|
||
|
||
class ServiceBusNamespaceNetworkrulesTest(BaseTest): | ||
def test_azure_servicebus_namespace_networkrules_schema_validate(self): | ||
p = self.load_policy({ | ||
'name': 'test-azure-servicebus-namespace-networkrules-schema-validate', | ||
'resource': 'azure.servicebus-namespace-networkrules' | ||
}, validate=True) | ||
self.assertTrue(p) | ||
|
||
def test_find_by_name(self): | ||
p = self.load_policy({ | ||
'name': 'test-azure-azure-servicebus-namespace-networkrules', | ||
'resource': 'azure.servicebus-namespace-networkrules', | ||
'filters': [ | ||
{'type': 'value', | ||
'key': 'name', | ||
'value': 'default'}], | ||
}) | ||
resources = p.run() | ||
self.assertEqual(len(resources), 1) |