Skip to content

Commit a52333d

Browse files
authored
Merge pull request #61 from StackPointCloud/master
API v4 update
2 parents 42ba420 + a3ac59f commit a52333d

20 files changed

Lines changed: 1957 additions & 250 deletions

README.md

Lines changed: 407 additions & 6 deletions
Large diffs are not rendered by default.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import os
2+
3+
from profitbricks.client import ProfitBricksService, Group, User
4+
5+
# Instantiate ProfitBricks connection
6+
client = ProfitBricksService(
7+
username=os.getenv('PROFITBRICKS_USERNAME'),
8+
password=os.getenv('PROFITBRICKS_PASSWORD'))
9+
10+
"""Create a group
11+
"""
12+
request = Group(
13+
name='demo-group',
14+
create_datacenter=True,
15+
create_snapshot=False,
16+
reserve_ip=True,
17+
access_activity_log=False)
18+
19+
group = client.create_group(request)
20+
21+
"""List groups
22+
"""
23+
groups = client.list_groups()
24+
25+
"""Create a user
26+
"""
27+
user_request = User(
28+
firstname='John',
29+
lastname='Doe',
30+
email='demo-user@example.com',
31+
password='SecretPassword123',
32+
administrator=True,
33+
force_sec_auth=False)
34+
35+
user = client.create_user(user_request)
36+
37+
"""List users
38+
"""
39+
users = client.list_users()
40+
41+
"""Add user to group
42+
"""
43+
# gu = client.add_group_user(group_id=group['id'], user_id=user['id'])
44+
# print json.dumps(gu, indent=4)
45+
46+
"""List group users
47+
"""
48+
gus = client.list_group_users(group_id=group['id'])
49+
50+
"""Delete group
51+
"""
52+
response = client.delete_group(group['id'])
53+
54+
"""Delete user
55+
"""
56+
response = client.delete_user(user['id'])
57+
58+
"""List all resources
59+
"""
60+
# listing all resources under an admin user may take a while
61+
resources = client.list_resources()
62+
63+
"""List ipblock resources
64+
"""
65+
ipblock_resources = client.list_resources(resource_type='ipblock')

profitbricks/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""ProfitBricks API Client Library for Python"""
2-
__version__ = '3.1.2'
2+
__version__ = '4.0.0'
33

4-
API_HOST = 'https://api.profitbricks.com/cloudapi/v3'
5-
API_VERSION = '3.0'
4+
API_HOST = 'https://api.profitbricks.com/cloudapi/v4'
5+
API_VERSION = '4.0'

0 commit comments

Comments
 (0)