Exemple #1
0
def datadog_monitor_delete(cmd,
                           client,
                           resource_group_name,
                           monitor_name,
                           no_wait=False):
    monitor = client.get(resource_group_name=resource_group_name,
                         monitor_name=monitor_name)
    poller = sdk_no_wait(no_wait,
                         client.begin_delete,
                         resource_group_name=resource_group_name,
                         monitor_name=monitor_name)
    result = poller.result()
    if not result:
        scrope = '/subscriptions/' + monitor.id.split('/')[2]
        role_assignments = list_role_assignments(cmd, role='43d0d8ad-25c7-4714-9337-8ba259a9fe05', scope=scrope)
        for i in role_assignments:
            if i.get('principalId') == monitor.identity.principal_id:
                delete_role_assignments(cmd, ids=[i.get('id')])
                break
    return poller
Exemple #2
0
 def test_role_assignment_delete_prompt(self, prompt_mock, client_mock):
     prompt_mock.return_value = False
     # action
     delete_role_assignments(mock.MagicMock())
     # assert
     prompt_mock.assert_called_once_with(mock.ANY, 'n')