File: v1_regions.py

package info (click to toggle)
python-vultr 1.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: python: 1,004; makefile: 5
file content (33 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'''Partial class to handle Vultr Regions API calls'''
from .utils import VultrBase, update_params


class VultrRegions(VultrBase):
    '''Handles Vultr Regions API calls'''
    def __init__(self, api_key):
        VultrBase.__init__(self, api_key)

    def availability(self, dcid, params=None):
        ''' /v1/regions/availability
        GET - public
        Retrieve a list of the VPSPLANIDs currently available
        in this location. If your account has special plans available,
        you will need to pass your api_key in in order to see them.
        For all other accounts, the API key is not optional.

        Link: https://www.vultr.com/api/#regions_region_available
        '''
        params = update_params(params, {'DCID': dcid})
        return self.request('/v1/regions/availability', params, 'GET')

    def list(self, params=None):
        ''' /v1/regions/list
        GET - public
        Retrieve a list of all active regions. Note that just
        because a region is listed here, does not mean that
        there is room for new servers.

        Link: https://www.vultr.com/api/#regions_region_list
        '''
        params = params if params else dict()
        return self.request('/v1/regions/list', params, 'GET')