Skip to content

Commit c63cc92

Browse files
author
Adam Heinz
committed
Adds resize option to linode Instance objects
Includes test.
1 parent e2de01d commit c63cc92

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

linode_api4/objects/linode.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,13 @@ def reboot(self):
348348
return False
349349
return True
350350

351+
def resize(self, new_type):
352+
resp = self._client.post("{}/resize".format(Instance.api_endpoint), model=self, data={"type": new_type})
353+
354+
if 'error' in resp:
355+
return False
356+
return True
357+
351358
@staticmethod
352359
def generate_root_password():
353360
def _func(value):

test/objects/linode_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ def test_boot(self):
160160
linode.boot()
161161
self.assertEqual(m.call_url, '/linode/instances/123/boot')
162162

163+
def test_resize(self):
164+
"""
165+
Tests that you can submit a correct resize api request
166+
"""
167+
linode = Instance(self.client, 123)
168+
result = {}
169+
170+
with self.mock_post(result) as m:
171+
linode.resize(new_type='g6-standard-1')
172+
self.assertEqual(m.call_url, '/linode/instances/123/resize')
173+
self.assertEqual(m.call_data, {'type': 'g6-standard-1'})
174+
163175
def test_boot_with_config(self):
164176
"""
165177
Tests that you can submit a correct boot with a config api request

0 commit comments

Comments
 (0)