Skip to content

Commit

Permalink
Merge pull request #8 from jwpeddle/master
Browse files Browse the repository at this point in the history
Add full_zone_set endpoint
  • Loading branch information
jlinn committed Sep 16, 2015
2 parents 637768c + dc806a7 commit d0f10ee
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pyflare/hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ def zone_set(self, user_key, zone_name, resolve_to, subdomains):
}
return self._request(params)

def full_zone_set(self, user_key, zone_name):
"""
Create new zone and all subdomains for user associated with this
user_key.
:param user_key: The unique 3auth string,identifying the user's
CloudFlare Account. Generated from a user_create or user_auth
:type user_key: str
:param zone_name: The zone you'd like to run CNAMES through CloudFlare for, e.g. "example.com".
:type zone_name: str
:returns:
:rtype: dict
"""
params = {
'act': 'full_zone_set',
'user_key': user_key,
'zone_name': zone_name,
}
return self._request(params)

def user_lookup(self, cloudflare_email=None, unique_id=None):
"""
Lookup user data based on either his cloudflare_email or his
Expand Down
1 change: 1 addition & 0 deletions tests/mock_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def wrapper(*args, **kw):
'user_create': json.dumps({'request': {'act': "user_create"}, 'response': {'cloudflare_email': "newuser@example.com", 'user_key': "8afbe6dea02407989af4dd4c97bb6e25", 'unique_id': "someuniqueid", 'cloudflare_username': "newuser23"}, 'result': "success", 'msg': "Your new CloudFlare account was created, you can login at www.cloudflare.com with the email address (newuser@example.com) and password."}),
'user_create_unique_id': json.dumps({'request': {'act': "user_create"}, 'response': {'cloudflare_email': "newuser@example.com", 'user_key': "8afbe6dea02407989af4dd4c97bb6e25", 'unique_id': "someuniqueid", 'cloudflare_username': "newuser23"}, 'result': "success", 'msg': "Your new CloudFlare account was created, you can login at www.cloudflare.com with the email address (newuser@example.com) and password."}),
'zone_set': json.dumps({'request': {'act': "zone_set"}, 'response': {'zone_name': "someexample.com", 'resolving_to': "cloudflare-resolve-to.someexample.com", 'hosted_cnames': {'www.someexample.com': "cloudflare-resolve-to.someexample.com", 'blog.someexample.com': "cloudflare-resolve-to.someexample.com", 'wordpress.someexample.com': "cloudflare-rs2.someexample.com"}, 'forward_tos': {'www.someexample.com': "www.someexample.com.cdn.cloudflare.net", 'blog.someexample.com': "blog.someexample.com.cdn.cloudflare.net", 'wordpress.someexample.com': "wordpress.someexample.com.cdn.cloudflare.net"} }, 'result': "success", 'msg': 'null'}),
'full_zone_set': json.dumps({'request': {'act': "full_zone_set"}, 'response': {'zone_name': "someexample.com", 'jumpstart': "true"}, 'result': "success", 'msg': 'null'}),
'user_lookup_email': json.dumps({'request': {'act': "user_lookup", 'unique_id': "someuniqueid"}, 'response': {'user_exists': 'true', 'cloudflare_email': "newuser@example.com", 'user_authed': 'true', 'user_key': "8afbe6dea02407989af4dd4c97bb6e25", 'unique_id': "someuniqueid", 'hosted_zones': ["someexample.com"] }, 'result': "success", 'msg': 'null'}),
'user_lookup_unique_id': json.dumps({'request': {'act': "user_lookup", 'unique_id': "someuniqueid"}, 'response': {'user_exists': 'true', 'cloudflare_email': "newuser@example.com", 'user_authed': 'true', 'user_key': "8afbe6dea02407989af4dd4c97bb6e25", 'unique_id': "someuniqueid", 'hosted_zones': ["someexample.com"] }, 'result': "success", 'msg': 'null'}),
'user_auth_password': json.dumps({'request': {'act': "user_auth"}, 'response': {'cloudflare_email': "newuser@example.com", 'user_key': "8afbe6dea02407989af4dd4c97bb6e25", 'unique_id': "someuniqueid"}, 'result': "success", 'msg': 'null'}),
Expand Down
15 changes: 15 additions & 0 deletions tests/test_pyflare_hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ def test_zone_set(self):
'cloudflare-resolve-to.someexample.com'
)

@mock_response_hosting
def test_full_zone_set(self):
response = self.pyflare.full_zone_set(
'user_key',
'someexample.com')

self.assertEqual(
response['response']['zone_name'],
'someexample.com'
)
self.assertEqual(
response['response']['jumpstart'],
'true'
)

@mock_response_hosting
def test_user_lookup_email(self):
response = self.pyflare.user_lookup(
Expand Down

0 comments on commit d0f10ee

Please sign in to comment.