-
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 resource (#8536)
- Loading branch information
Showing
7 changed files
with
177 additions
and
1 deletion.
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
39 changes: 39 additions & 0 deletions
39
tools/c7n_azure/c7n_azure/resources/servicebus_namespace.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,39 @@ | ||
# Copyright The Cloud Custodian Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from c7n_azure.provider import resources | ||
from c7n_azure.resources.arm import ArmResourceManager | ||
|
||
|
||
@resources.register('servicebus-namespace') | ||
class ServiceBusNamespace(ArmResourceManager): | ||
"""Azure Service Bus Namespace Resource | ||
:example: | ||
Returns Service Bus Namespace resources | ||
.. code-block:: yaml | ||
policies: | ||
- name: basic-servicebus-namespace | ||
resource: azure.servicebus-namespace | ||
filters: | ||
- type: value | ||
key: authorizationRules | ||
value: present | ||
""" | ||
|
||
class resource_type(ArmResourceManager.resource_type): | ||
doc_groups = ['Events'] | ||
|
||
service = 'azure.mgmt.servicebus' | ||
client = 'ServiceBusManagementClient' | ||
enum_spec = ('namespaces', 'list', None) | ||
default_report_fields = ( | ||
'name', | ||
'location', | ||
'resourceGroup' | ||
) | ||
resource_type = 'Microsoft.ServiceBus/namespaces' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
68 changes: 68 additions & 0 deletions
68
tools/c7n_azure/tests_azure/cassettes/ServiceBusNamespaceTest.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,68 @@ | ||
{ | ||
"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": { | ||
"content-type": [ | ||
"application/json; charset=utf-8" | ||
], | ||
"date": [ | ||
"Thu, 04 May 2023 15:30:01 GMT" | ||
], | ||
"cache-control": [ | ||
"no-cache" | ||
], | ||
"x-ms-inline-count": [ | ||
"" | ||
], | ||
"server-sb": [ | ||
"Service-Bus-Resource-Provider/SN1" | ||
], | ||
"content-length": [ | ||
"745" | ||
] | ||
}, | ||
"body": { | ||
"data": { | ||
"value": [ | ||
{ | ||
"sku": { | ||
"name": "Standard", | ||
"tier": "Standard" | ||
}, | ||
"id": "/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/resourceGroups/test_servicebus/providers/Microsoft.ServiceBus/namespaces/cctestservicebusnamespacejv67tef5di5hy", | ||
"name": "cctestservicebusnamespacejv67tef5di5hy", | ||
"type": "Microsoft.ServiceBus/Namespaces", | ||
"location": "East US", | ||
"tags": { | ||
"product_id": "13742" | ||
}, | ||
"properties": { | ||
"disableLocalAuth": false, | ||
"zoneRedundant": false, | ||
"provisioningState": "Succeeded", | ||
"metricId": "ea42f556-5106-4743-99b0-c129bfa71a47:cctestservicebusnamespacejv67tef5di5hy", | ||
"createdAt": "2023-05-04T15:28:25.363Z", | ||
"updatedAt": "2023-05-04T15:29:08.213Z", | ||
"serviceBusEndpoint": "https://cctestservicebusnamespacejv67tef5di5hy.servicebus.windows.net:443/", | ||
"status": "Active" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
tools/c7n_azure/tests_azure/templates/servicebus-namespace.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,24 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"namespaceName": { | ||
"type": "string", | ||
"defaultValue": "[concat('cctestservicebusnamespace', uniqueString(resourceGroup().id))]" | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.ServiceBus/namespaces", | ||
"apiVersion": "2021-11-01", | ||
"name": "[parameters('namespaceName')]", | ||
"location": "eastus", | ||
"properties": { | ||
"sku": { | ||
"name": "Standard" | ||
}, | ||
"enableHttpsTrafficOnly": true | ||
} | ||
} | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
tools/c7n_azure/tests_azure/tests_resources/test_servicebus_namespace.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 ServiceBusNamespaceTest(BaseTest): | ||
def test_azure_servicebus_namespace_schema_validate(self): | ||
p = self.load_policy({ | ||
'name': 'test-azure-servicebus-namespace-schema-validate', | ||
'resource': 'azure.servicebus-namespace' | ||
}, validate=True) | ||
self.assertTrue(p) | ||
|
||
def test_find_by_name(self): | ||
p = self.load_policy({ | ||
'name': 'test-azure-azure-servicebus-namespace', | ||
'resource': 'azure.servicebus-namespace', | ||
'filters': [ | ||
{'type': 'value', | ||
'key': 'name', | ||
'value': 'cctestservicebusnamespacejv67tef5di5hy'}], | ||
}) | ||
resources = p.run() | ||
self.assertEqual(len(resources), 1) |