def test_api_params_for_state_reset(self):
     expected_output = {
         'method':
         'POST',
         'endpoint':
         'https://api.phoenixnap.com/bmc/v1/servers/some_server_id/actions/reset',
         'data':
         json.dumps(
             {
                 'installDefaultSshKeys': True,
                 'sshKeys': 'xxx',
                 'sshKeyIds': '123',
                 'osConfiguration': {
                     'windows': {
                         'rdpAllowedIps': '1.1.1.1'
                     },
                     'esxi': {
                         'managementAccessAllowedIps': '1.1.1.1'
                     }
                 }
             },
             sort_keys=True)
     }
     self.assertDictEqual(
         get_api_params(PseudoModule(), 'some_server_id', 'reset'),
         expected_output)
 def test_api_params_for_state_absent(self):
     expected_output = {
         'method': 'DELETE',
         'endpoint':
         'https://api.phoenixnap.com/bmc/v1/servers/some_server_id',
         'data': 'null'
     }
     self.assertDictEqual(get_api_params(None, 'some_server_id', 'absent'),
                          expected_output)
 def test_api_params_for_state_absent(self):
     expected_output = {
         'method': 'POST',
         'endpoint':
         'https://api.phoenixnap.com/bmc/v1/servers/some_server_id/actions/deprovision',
         'data': json.dumps({'deleteIpBlocks': True}, sort_keys=True)
     }
     self.assertDictEqual(
         get_api_params(PseudoModule(), 'some_server_id', 'absent'),
         expected_output)
 def test_api_params_for_state_rebooted(self):
     expected_output = {
         'method': 'POST',
         'endpoint':
         'https://api.phoenixnap.com/bmc/v1/servers/some_server_id/actions/reboot',
         'data': 'null'
     }
     self.assertDictEqual(
         get_api_params(None, 'some_server_id', 'rebooted'),
         expected_output)
 def test_api_params_for_state_present(self):
     expected_output = {
         'method':
         'POST',
         'endpoint':
         'https://api.phoenixnap.com/bmc/v1/servers/',
         'data':
         json.dumps(
             {
                 'description': 'some description',
                 'location': 'PHX',
                 'hostname': 'my-server-red',
                 'installDefaultSshKeys': True,
                 'sshKeys': 'xxx',
                 'sshKeyIds': '123',
                 'networkType': 'PUBLIC_AND_PRIVATE',
                 'os': 'ubuntu/bionic',
                 'reservationId': '1',
                 'pricingModel': 'HOURLY',
                 'type': 's1.c1.small',
                 'osConfiguration': {
                     'windows': {
                         'rdpAllowedIps': '1.1.1.1'
                     },
                     'managementAccessAllowedIps': '1.1.1.1'
                 },
                 'networkConfiguration': {
                     'gatewayAddress': '182.16.0.145',
                     'privateNetworkConfiguration': {
                         'configurationType': 'USE_OR_CREATE_DEFAULT'
                     },
                     'ipBlocksConfiguration': {
                         'configurationType': 'USER_DEFINED',
                         'ipBlocks': [{
                             'id': '11111'
                         }]
                     }
                 }
             },
             sort_keys=True)
     }
     self.assertDictEqual(
         get_api_params(PseudoModule(), 'my-server-red', 'present'),
         expected_output)