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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# -*- encoding: utf-8 -*-
import json
try:
from ovh import ovh
except ImportError:
# In case it's installed globally
import ovh
import sys
import ovh_helper
# Credentials are stored in ~/.ovh.conf
# See ovh/README.rst
client = ovh.Client()
# Create a cart
cart = client.post('/order/cart', ovhSubsidiary="FR")
cart_id = cart["cartId"]
# Assign it to my user
client.post('/order/cart/{}/assign'.format(cart_id))
# list of vps:
# client.get('/order/cart/{}/vps'.format(cart_id))
item = client.post('/order/cart/{}/vps'.format(cart_id),
duration="P1M",
planCode="vps_ssd_model1",
pricingMode="default",
quantity=1)
item_id = item["itemId"]
# Datacenter, OS, auto-renew
client.post('/order/cart/{}/item/{}/configuration'.format(cart_id, item_id),
label="vps_ssd_datacenter",
value="gra")
client.post('/order/cart/{}/item/{}/configuration'.format(cart_id, item_id),
label="vps_ssd_os",
value="linux--archlinux--64--en")
client.post('/order/cart/{}/item/{}/configuration'.format(cart_id, item_id),
label="AUTO_RENEW_VPS",
value=False)
#summary = client.get('/order/cart/{}/summary'.format(cart_id))
#checkout = client.get('/order/cart/{}/checkout'.format(cart_id))
# Checkout
order = client.post('/order/cart/{}/checkout'.format(cart_id),
waiveRetractationPeriod=True)
order_id = order["orderId"]
print(order_id)
# Suite à tester :
# /me/order/{orderId}/availableRegisteredPaymentMean
# /me/paymentMean ? /me/order/{orderId}/debt/pay ?
|